Skip to content

Instantly share code, notes, and snippets.

@jashkenas
Forked from rahulkmr/portfwd.js
Created February 9, 2010 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jashkenas/299376 to your computer and use it in GitHub Desktop.
Save jashkenas/299376 to your computer and use it in GitHub Desktop.
tcp: require 'tcp'
server: tcp.createServer (socket) ->
client: null
socket.addListener 'connect', ->
client: tcp.createConnection 22
client.addListener 'receive', (data) -> socket.send(data)
client.addListener 'eof', -> client.close()
socket.addListener 'receive', (data) -> client.send(data)
socket.addListener 'eof', ->
# Communication complete.
triggerCallback()
socket.close()
server.listen 7000, 'localhost'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment