title: Node.js: how to flush socket?
body: <p>I'm trying to flush a socket before sending the next chunk of the data:</p>
  
  <pre><code>var net = require('net');
  
  net.createServer(function(socket) {
      socket.on('data', function(data) {
          console.log(data.toString());
      });
  }).listen(54358, '127.0.0.1');
  
  var socket = net.createConnection(54358, '127.0.0.1');
  
  socket.setNoDelay(true);
  socket.write('mentos');
  socket.write('cola');
  </code></pre>
  
  <p>This, however, doesn't work despite the <code>setNoDelay</code> option, e.g. prints "mentoscola" instead of "mentos\ncola". How do I fix this?</p>