Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are using TCP then the interface presented to you is that of a stream of bytes. You don't need to worry about how the stream of bytes gets from one end of the connection to the other. You can ignore the IP layer's MTU. In fact you can ignore the IP layer entirely. </p> <p>When you call <code>send()</code> the TCP stack on your machine will deal with all the details necessary for the stream of bytes that you are pushing into your send calls to appear from <code>recv()</code> calls at the other end of the connection.</p> <p>The one thing to remember is that with TCP you are dealing with a stream and that means that one <code>send()</code> may result in data arriving in multiple <code>recv()</code> calls and multiple <code>send()</code> calls may result in data arriving in a single <code>recv()</code> call. You have no control over this. You are dealing with a stream of bytes and each call to <code>recv()</code> can return any number of bytes from 1 to the number currently outstanding (allowing for adequate buffers passed to the <code>recv()</code> call).</p> <p>Since the commenters asked for it ;)</p> <p>On most TCP stacks <code>send()</code> is most likely to fail to send everything because the TCP stack's buffers are full and (probably) the TCP window is also full and flow control is in operation which means that the stack can't send any more data until the remote end ACKs some data and it's not prepared to buffer any more on your behalf. I've not come across a TCP stack that will refuse a <code>send()</code> due to MTU considerations alone but I guess some slimmed down embedded systems might behave that way... </p> <p>Anyway, if <code>send()</code> returns less than the number of bytes that you supplied it then you should resend the remaining data at some point. Often <code>send()</code> will block and wait until it can send all of the data, and if you've set the socket into non blocking mode then you probably do NOT want to immediately retry the send if it fails to send everything as you'll likely end up in a tight loop...</p> <p>It would probably be useful for you to be more specific about the operating system that you're using.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload