Created
July 24, 2010 17:42
-
-
Save gleicon/488845 to your computer and use it in GitHub Desktop.
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
var net = require('net'); | |
var sys = require('sys'); | |
function repr(wot) { | |
sys.puts(sys.inspect(wot)); | |
} | |
net.createServer(function (socket) { | |
//repr(socket); | |
client = net.createConnection(8888); | |
socket.setEncoding('utf-8'); | |
client.setEncoding('utf-8'); | |
socket.addListener("connect", function () { | |
sys.log("Connection from " + socket.remoteAddress+" Port: " + socket.remotePort); | |
}); | |
client.addListener("data", function (data) { | |
sys.log("outgoing: " + data); | |
socket.write(data); | |
}); | |
socket.addListener("data", function (data) { | |
sys.log("incoming: " + data); | |
client.write(data); | |
}); | |
socket.addListener("end", function () { | |
sys.log("Connection from " + socket.remoteAddress+" Port: " + socket.remotePort +" has ended"); | |
socket.end(); | |
}); | |
}).listen(9000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment