Created
October 19, 2010 20:44
-
-
Save pedrofaria/635072 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
var net = require('net'); | |
var global = []; | |
net.createServer(function (socket) { | |
socket.setEncoding("utf8"); | |
socket.on('connect', function() { | |
socket.write("Echo server - "+ socket.fd +"\r\n"); | |
}); | |
socket.on("data", function (data) { | |
try { | |
var x = JSON.parse(data); | |
socket.write(JSON.stringify(x)); | |
} | |
catch (err) { | |
socket.write('Unkown command... you suck!\r\n'); | |
} | |
}); | |
socket.on("end", function () { | |
socket.end(); | |
}); | |
}).listen(8124, "127.0.0.1"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment