title: socket.io - works first time, not second time onwards
body: <p>When I start my node.js server and client gets connected, I am able to send a request from client (socket.emit) and get a response (socket.on('rentsAround'....)). But when I connect 2nd time onwards, the client is able to send, but server can not send or emit. So I have to restart the server again. I understand that it is working as expected, but somehow my understanding is wrong somewhere... Would someone please point out.</p>
  
  <p><strong>client side:
  ========</strong></p>
  
  <pre><code>    var socket = new io.Socket();
      socket = io.connect();
  
      socket.on('rentsAround', function(data){
          registration.handleRentsAround(data);
      });
  
  
      socket.on('locationDetailsRes', function(data){
          registration.handleRentsAround(data);
      });
  
      socket.on('connect', function(data){
          alert('inside connect on client side');
      });
  
  socket.on('disconnect', function(){ 
      // do something, if you want to. 
      });
      .............
      socket.emit("searchRent",  {"lat":lat, "lng":lng});
  </code></pre>
  
  <p><strong>server side:
  ========</strong></p>
  
  <pre><code>socket.sockets.on('connection', function(client){ 
  
              client.on('searchRent', function(msg){
          console.log('inside on connection');
                  // do something and reply back
          client.emit('rentsAround',{"totalRents":docs.length, "rents":docs});
              });
  
     client.on('disconnect', function(){ 
          sys.puts("client disconnect"); 
          mongoose.disconnect();
          }); 
  </code></pre>