title: How to stop a node.js server without killing the process?
body: <p>Say a server is created like:</p>
  
  <pre><code>var net = require('net');
  
  var server = net.createServer();
  server.listen(32323, '127.0.0.1');
  
  server.close(); // gives a "not running" error if there is IP in the listen statement
  </code></pre>
  
  <p>is there a way to stop it from node.js, e.g. without ending/killing the whole process?</p>
  
  <p>Also, here's a more complicated example that doesn't stop regardless of the IP the server is bound to:</p>
  
  <pre><code>var net = require('net');
  
  var server = net.createServer(function(socket) {
      socket.on('data', console.log);
      server.close();
  });
  
  server.listen(32323);
  
  var socket = net.createConnection(32323);
  socket.write('hi');
  </code></pre>