title: How does TCP_NODELAY affect consecutive write() calls?
body: <p>TCP_NODELAY is an option to enable quick sending of TCP packets, regardless of their size. This is very useful option when speed matters, however, I'm curious what it will do to this:</p>
  
  <pre><code>Socket socket = [some socket];
  socket.setTcpNoDelay(true);
  OutputStream out = socket.getOutputStream();
  out.write(byteArray1);
  out.write(byteArray2);
  out.write(byteArray3);
  out.flush();
  </code></pre>
  
  <p>I tried to find what flush actually does on a <code>SocketOutputStream</code>, but as far as I know now, it doesn't do anything. I had hoped it would tell the socket "send all your buffered data NOW", but, unfortunately, no it doesn't.</p>
  
  <p>My question is: are these 3 byte arrays sent in one packet? I know you don't have much control over how TCP constructs a network packet, but is there any way to tell the socket to (at least try to) pack these byte arrays, so network overhead is avoided? Could manually packing the byte arrays and sending them in one call to <code>write</code> help?</p>