title: C# Socket.Send( ): does it send all data or not?
body: <p>I was reading about sockets from a book called "C# Network Programming" by Richard Blum.  The following excerpt states that the Send() method is not guaranteed to send all the data passed to it. </p>
  
  <blockquote>
  <pre><code>byte[] data = new byte[1024];
  int sent = socket.Send(data);
  </code></pre>
    
    <p>On the basis of this code, you might be tempted to presume that the
    entire 1024-byte data buffer was sent to the remote device... but this
    might be a bad assumption.  Depending on the size of the internal TCP
    buffer and how much data is being transferred, it is possible that not
    all the data supplied to the Send() mehtod was actually sent.</p>
  </blockquote>
  
  <p>However, when I went and looked at the Microsoft documentation <a href="https://msdn.microsoft.com/en-us/library/w93yy28a(v=vs.110).aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/w93yy28a(v=vs.110).aspx</a> it says:</p>
  
  <blockquote>
    <p>If you are using a connection-oriented protocol, Send will block until
    all of the bytes in the buffer are sent, unless a time-out was set</p>
  </blockquote>
  
  <p>So which is it?  The book was published in 2004, so has it changed since then?  </p>
  
  <p>I'm planning to use asynchronous sockets, so my next question is, would BeginSend() send all data?</p>