Chris Mendez in NodeJS, For Developers

Simple NodeJS TCP

This is the simplest NodeJS app you can make that uses TCP.

var net = require('net');

var server = net.createServer( onServerHandler );  
    server.listen(8080, 'http://localhost');  

function onServerHandler(socket) {  
  socket.write('Echo server\r\n');
  socket.pipe(socket);
};