Created
May 10, 2011 16:19
-
-
Save kennyj/964794 to your computer and use it in GitHub Desktop.
node.js echo server (coffeescript)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
net = require 'net' | |
sockets = [] | |
server = net.createServer (socket) -> | |
sockets.push socket | |
socket.on 'data', (d) -> | |
s.write d for s in sockets | |
socket.on 'end', -> | |
sockets.splice sockets.indexOf(socket) | |
server.listen 8000 | |
---- | |
$ coffee server.coffee |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment