title: Why do SocketChannel writes always complete for the full amount even on non-blocking sockets?
body: <p>Using the Sun Java VM 1.5 or 1.6 on Windows, I connect a non-blocking socket. I then fill  a <code>ByteBuffer</code> with a message to output, and attempt to <code>write()</code> to the SocketChannel.</p>
  
  <p>I expect the write to complete only partially if the amount to be written is greater than the amount of space in the socket's TCP output buffer (this is what I expect intuitively, it's also pretty much my understanding of the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/nio/channels/SocketChannel.html#write(java.nio.ByteBuffer)" rel="noreferrer">docs</a>), but that's not what happens. The <code>write()</code> <em>always</em> seems to return reporting the full amount written, even if it's several megabytes (the socket's SO_SNDBUF is 8KB, much, much less than my multi-megabyte output message).</p>
  
  <p>A problem here is that I can't test the code that handles the case where the output is partially written (registering an interest set of <code>WRITE</code> to a selector and doing a <code>select()</code> to wait until the remainder can be written), as that case never seems to happen. What am I not understanding?</p>