title: nonblocking send()/write() and pending data dealing
body: <p>when the send(or write) buffer is going to be full, let me say, only theres is only 500 bytes space. if I have a NONBLOCKING fd, and do </p>
  
  <pre><code>  n = send(fd, buf, 1000,0)
  </code></pre>
  
  <p>here I wll get n&lt;0, and I can get EWOULDBLOCK or EAGAIN error. my questions are:</p>
  
  <p>1 here, the <code>send</code> write 500 bytes into the send buffer or 0 bytes to the send buffer?</p>
  
  <p>2 if 500 bytes are sent to the buffer and if the fd is a UDP socket, then the datagram is split into 2 parts? </p>
  
  <p>3 I need to use the <code>fd</code> to send many datagrams, if this time the send buffer is full(if there is EWOULDBLOCK or EAGAIN error), I need to make a pending list of datagrams(a FIFO queue). And everytime I want to send some datagram, I will have to check the pending list to see whether it is empty or not. if it is not empty, send the datagram in the pending list first.  It seems to me that this design is a bit troublesome.  And the design is similar to extending the kernel(BTW, is it in the kernel?) send buffer by a userspace pending list. Is there better solution for this?</p>
  
  <p>thanks!</p>