var net = require('net'),
clientSocket = new net.Socket();
clientSocket.setEncoding('utf8');
clientSocket.connect('8080', 'localhost', function(){
console.log('Connected!');
clientSocket.write('Hello!');
});
clientSocket.on('data', function(data) {
console.log('data: ' + data);
});
clientSocket.on('close', function() {
console.log('Bye!');
});