Skip to content

Instantly share code, notes, and snippets.

@kennyj
Created May 10, 2011 16:19
Show Gist options
  • Save kennyj/964794 to your computer and use it in GitHub Desktop.
Save kennyj/964794 to your computer and use it in GitHub Desktop.
node.js echo server (coffeescript)
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