hi,

At the function call below, flag parameter has been set to 0. What is the point in setting it to zero ?


        push 0
push 100
push esi
push
call recv

       
Posted on 2011-08-14 06:23:42 by hakand
No flags wanted.
Posted on 2011-08-14 06:31:52 by Homer
homer can we read one byte at a time with the code below?
(for example esi points to a 100 byte-buffer)


        push 0
push 1
push esi
push
call recv
Posted on 2011-08-17 09:53:29 by hakand
You can, but that's a horrible way to make use of the TCP/IP stack.  It's better to simply call recv() with the maximum buffer space you have and let it fill in the bytes received from the packets. 
Posted on 2011-08-17 20:32:57 by p1ranha
Note that recv() returns the #bytes that it actually managed to read.. or zero (disconnected). This means you can just read (up to max buffersize) #bytes, and then check how much you actually received.... yeah, what he said (lol).

Try not to make assumptions about networking stuff, example "if I send a packet of 1000 bytes with a single call, I should receive a packet of 1000 bytes with a single call".
Don't assume ANYTHING, check your return values :)

Posted on 2011-08-18 03:29:31 by Homer

Try not to make assumptions about networking stuff, example "if I send a packet of 1000 bytes with a single call, I should receive a packet of 1000 bytes with a single call".
Don't assume ANYTHING, check your return values :)


This is so very true.  As a general rule: You will spend more time writing TCP/IP error checking code than the code to handle the parsing of that data.  It's far better to abstract this logic into a library of reusable code.  Also make sure you understand synchronous/asynchronous and blocking/non-blocking modes.  Your initial design choices will have a huge impact on how you code.
Posted on 2011-08-18 06:06:15 by p1ranha