title: Correct way to restart a socket.io server
body: <p>I'm trying to restart a socket.io server.  I start the server and get a welcome message for new connections, but when I close and restart the server I get no further welcome message.  </p>
  
  <p>Hopefully I'm missing something simple :\</p>
  
  <pre><code>var http = require('http').Server
  var socketIO = require('socket.io')
  var socketIOClient = require('socket.io-client')
  var port   = 3000
  var url = 'ws://localhost:' + port
  
  function newServer(serverName, cb)
  {
      var server = http().listen(port, function()
      {
          console.log(serverName, 'listening')
          var io = socketIO(server)
  
          var clientSocket = socketIOClient(url,
              { reconnection: false })
  
          clientSocket.on('connect', function()
          {
              // never get 'two connect'
              console.log(serverName, 'connect')
              io.close()
          })
          clientSocket.on('disconnect', function()
          {
              console.log(serverName, 'disconnect')
              cb()
          })
      })
  }
  
  function startServerOne(cb)
  {
      newServer('one', cb)
  }
  function startServerTwo(cb)
  {
      newServer('two', cb)
  }
  
  startServerOne(startServerTwo)
  </code></pre>