513f6358   
   From: rick.jones2@hp.com   
      
   lmike wrote:   
   > When does it return when I do a write(socket_fd, buffer, buffer_len)   
   > on a blocking TCP socket(i.e. the socket_fd)?   
   > Does it return:   
   > (1) when the TCP stack has enough buffer to hold the whole data   
   > (i.e. buffer_len of buffer data) to be sent out, but not necessary   
   > the whole buffer is sent out? Can write in this case return a number   
   > smaller than "buffer_len" (not -1)?   
   > (2) it returns when the receiver sends ACK(s) back, and the system   
   > knows that all bytes in the buffer are received by the receiver?   
      
   "It depends" :)   
      
   Whether a write()/send()/whatnot completes when TCP has copied the   
   data or when the remote has ACKnowledged the data depends on the stack   
   and settings. IIRC if one asks for copy avoidance in the Windows TCP   
   stack, a given send() may not complete until the TCP is done with the   
   buffer, which would be when it was ACKed.   
      
   Whether a write()/send()/whatnot could return a number smaller than   
   the requested number of bytes to be written will depend on the   
   blocking/non-blocking status of the socket.   
      
   rick jones   
   --   
   Process shall set you free from the need for rational thought.   
   these opinions are mine, all mine; HP might not want them anyway... :)   
   feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|