Re: Winsock recv() and unfragmented packets

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Apr 19, 7:44 am, re_ductor <re_duc...@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Hi all,

I was wondering if a call to recv() will return all data for an unfragmented
packet. Suppose i'm setting up a TCP connection over the Internet, once the
connection has been established the client starts sending some data using
exactly one call to send(). (well under the 536 (576 minus 40 header bytes)
byte limit that might casue fragmentation). From what I understand this
packet shouldn't be fragmented so it'll arrive on the server in one piece..
Does this mean that when calling recv() with a large enough buffer will
return the entire packet or can winsock itself decide that i have to call
recv() more than once to get all the data to the unfragmented data?

Note that i'm fully aware of the fact that recv() can return data for more
than one packet. But i'm talking about a single call to send() that transmits
no more bytes than IP's fragmentaiton limit and then simply waits for the
server to reply. So it should make sense (From TCP/IP's standpoint of view at
least) that a call to recv() with a large enough buffer returns all the data,
is this assumption correct?

tcp is a stream. That means there is no implicit "record boundary."
You should not rely on it. You also don't know what kind of buffering
the OS on the server might do. There are many vagaries involved, for
example, when the server writes the data, does it go into small
buffers in the OS and maybe sent while the process is swapped out? If
you really want packets, you have to code for it. You can use udp in
place of tcp but you give up a lot of useful functionality to do that.

/steveA

.



Relevant Pages

  • Interesting TCP behaviour with large sends/small buffers
    ... The server, upon connection, sends a configurable number of bytes to ... I set the client's receive buffer size to 1MBps, ... packet before sending the next packet. ... ACK, according to the delayed ACK algorithm - 50KB bytes means 34 MSS- ...
    (microsoft.public.win32.programmer.networks)
  • Re: Interesting TCP behaviour with large sends/small buffers
    ... The server, upon connection, sends a configurable number of bytes to ... I set the client's receive buffer size to 1MBps, ... packet before sending the next packet. ... ACK, according to the delayed ACK algorithm - 50KB bytes means 34 MSS- ...
    (microsoft.public.win32.programmer.networks)
  • Re: Interesting TCP behaviour with large sends/small buffers
    ... My current workaround is simply setting the send buffer to a larger ... The server, upon connection, sends a configurable number of bytes to ... packet before sending the next packet. ... ACK, according to the delayed ACK algorithm - 50KB bytes means 34 MSS- ...
    (microsoft.public.win32.programmer.networks)
  • Re: Interesting TCP behaviour with large sends/small buffers
    ... The server, upon connection, sends a configurable number of bytes to ... I set the client's receive buffer size to 1MBps, ... packet before sending the next packet. ... ACK, according to the delayed ACK algorithm - 50KB bytes means 34 MSS- ...
    (microsoft.public.win32.programmer.networks)
  • Re: Synchronization with CAsyncSocket in CE 6.0
    ... number of bytes in the first packet, followed by packets of, say 1024 bytes. ... recv() operations, reassembling it into the format that you need. ... don't forget that recv can return zero, if the socket has ... So, CAsyncSocket while possibly a bad way to do things, does not appear to ...
    (microsoft.public.windowsce.embedded)