I have this simple TCP server:
var net = require('net');
var server = net.createServer(function (socket) {
socket.on('connect', function() {
console.log("New client!");
});
});
server.listen(8000, function(){
console.log("server running...")
});
and then I have another file as client.js:
var net = require('net');
var client = net.connect({port: 8000},
function() {
console.log('client connected');
});
client.on('error', console.error);
I run server in one terminal window and then I run client in other window and expect to see server log "New Client". Although, that doesn't happen. So, when is the 'connect' event exactly emitted?