Simple node.js socket listener

This simple snippet just writes back everything it receives, but it’s a useful test:

var net = require('net');
net.createServer(function(socket){
 socket.on('data', function(data) {
 socket.write(data);
 });
}).listen(1337);
Advertisements