socket = new io.Socket('localhost'); socket.connect(); socket.on('connect', function(){ // connected }); socket.on('message', function(data){ // data here }); socket ...