Hello all,

i have a winsock problem here.. i am trying to send a file which is quite big (127MBs in this case) and i am getting the "Not enough buffer space .." error, or WSAENOBUFS! why is this!?!? if i try to send a smaller file it sends just fine! I only have 2 socks opened and i am using win98.
anybody knows whats going on here/!?!?!?!?!?

Thanks to all !
Posted on 2002-06-23 16:17:44 by Ray
What I have found is that error means "Insufficient buffer space is available", I don't know exactly why this is, but you might try setting your buffer bigger, and/or flushing it. I don't know why your buffer space would cause problems, the system is suppose to take care of that for you....I thought that once the buffer gets full the system flushes it.
Posted on 2002-06-24 08:26:45 by gorshing
well,
thats what i thought as well. Which buffer do you suggest to flush?

here is the code in question:
.....
mov eax,BytesSend
mov ecx,fSize
sub ecx,eax
; Get the right buffer ptr
add eax, mPtr

invoke send,iSock,eax,ecx,NULL
......

the fsize holds the size of the file.
the mPtr is a pointer to a memory which holds the data to send.
The above works fine with files 3-4Mbs. If you try a 40Mb file though i get the error.

I have tried sending 4096 bytes in a loop but this decrease the tranfer dramatically!

what are your suggestions ?
Posted on 2002-06-24 12:36:20 by Ray
It's not a very good idea to send such a huge buffer at once. Read the file in blocks and send one block at a time instead.

Thomas
Posted on 2002-06-24 12:47:08 by Thomas
I would like to know why sending in 4096 would cause it to decline in speed so bad. Maybe there is a bunch going on under the hood, that I'm not seeing?

Anyways I would just up the buffer size to like a Meg or 2, try that and see what it does.....maybe.
Posted on 2002-06-24 14:42:33 by gorshing
gorshing,
for that question i guess you should ask Thomas :) I am not really sure why sending 4096 bytes is quite slower, but in my case its true.
After your suggestions i tried sending blocks of 1Mb and 512k. I have found that 512k is much faster . ( using localhost )
Posted on 2002-06-25 01:27:52 by Ray
It's probably because of *some kind* of overhead. I'm not sure but winsock can probably optimize better when it gets larger blocks, however it isn't prepared for really large blocks (serveral MBs).

It also depends on your I/O method.. blocking sockets are slower than non-blocking sockets. Event notification (WSAEventSelect) using event objects is a lot faster than using window messages (WSAAsyncSelect). Overlapped I/O is one of fastest method but quite complicated.

I also remember some post about TransmitFile, which should be pretty fast because it handles file I/O better (IIRC it does it's I/O at kernel level), but you'll loose a bit of control when using this function.

An interesting thread about transfer speeds can be find here:
http://www.asmcommunity.net/board/index.php?topic=1874

Thomas
Posted on 2002-06-25 11:46:41 by Thomas
Greetings Thomas,

indeed it looks quite fast using WSAEventSelect in an independent thread :)

Thanks for the link, even though i know that thread very well :) hhehhe..i started it:):alright:

now, how about that winsock tutorial?? have you got a chance to work on it??
Posted on 2002-06-26 01:27:23 by Ray
now, how about that winsock tutorial?? have you got a chance to work on it??


It's the usual excuse, lack of time :(.. I did finish five pages or so (still in the old layout of my site) but haven't had a chance to work on it again.

Maybe I should publish the parts as I write..

Thomas
Posted on 2002-06-27 14:12:38 by Thomas
That will be great Thomas :grin:
let us know when you publish em .
Posted on 2002-06-28 01:16:42 by Ray