Created
July 21, 2010 01:08
-
-
Save dcoder2099/483884 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// This is a TCP server which listens at 127.0.0.1:8203 | |
// All it does is log everything sent across the wire to the console. | |
// Send ^D as first char of buffer to shut down. | |
var net = require('net'); | |
var CONTROL_D = String.fromCharCode(4); | |
net.createServer(function (socket) { | |
socket.setEncoding("utf8"); | |
socket.write("Logging Test Server\r\n"); | |
socket.on("data", function (data) { | |
console.log(data); | |
if (data.charCodeAt(0) == 4) { | |
socket.write('^D received, hasta!\r\n') | |
socket.end(); | |
} | |
}); | |
socket.on("end", function () { | |
socket.end(); | |
}); | |
}).listen(8203, "127.0.0.1"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment