title: Blocking sockets: when, exactly, does "send()" return?
body: <p>When, exactly, does the BSD socket <code>send()</code> function return to the caller?</p>
  
  <p>In <em>non-blocking mode</em>, it should return immediately, correct?</p>
  
  <p>As for <em>blocking</em> mode, the <a href="http://manpages.ubuntu.com/manpages/lucid/man2/send.2.html" rel="noreferrer">man page</a> says:</p>
  
  <blockquote>
    <p>When  the  message  does  not  fit  into the send buffer of the socket, <strong>send()</strong> normally blocks, unless the  socket  has  been  placed  in  non-blocking  I/O  mode.</p>
  </blockquote>
  
  <p>Questions:</p>
  
  <ol>
  <li>Does this mean that the <code>send()</code> call will always return immediately if there is room in the kernel send buffer?</li>
  <li>Is the behavior and performance of the <code>send()</code> call identical for TCP and UDP? If not, why not?</li>
  </ol>