Skip to content

Instantly share code, notes, and snippets.

@vcanales
Last active August 29, 2015 14:19
Show Gist options
  • Save vcanales/87cf8bc20a86d0ce355d to your computer and use it in GitHub Desktop.
Save vcanales/87cf8bc20a86d0ce355d to your computer and use it in GitHub Desktop.
This configuration leaves express running on ports 3000 and 3030.
// This configuration leaves express running on ports 3000 and 3030. I need to avoid that. Help!
var server = app.listen(3030, function() {
debug('Express server listening on port '+ server.address().port);
});
var io = require('socket.io')(server);
var connections = 0;
io.sockets.on('connection', function(socket) {
connections++;
console.log('client connected ('+connections+' total)');
socket.emit('info', { clients: connections });
socket.on('disconnect',function() {
connections--;
console.log('client disconnected ('+connections+' left)');
io.sockets.emit('info', { clients: connections });
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment