Skip to content

Instantly share code, notes, and snippets.

@cdolan
Created September 12, 2012 00:37
Show Gist options
  • Save cdolan/3703296 to your computer and use it in GitHub Desktop.
Save cdolan/3703296 to your computer and use it in GitHub Desktop.
var net = require('net');
var chatroom = [];
var server = net.createServer(function(user) {
user.on('connect', function() {
console.log('user connected');
chatroom.push(user);
});
user.on('data', function(data) {
for (var i = 0; i < chatroom.length; i++) {
chatroom[i].write(data);
}
});
user.on('end', function() {
console.log('user disconnected');
});
});
server.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment