tags:

views:

45

answers:

1

How can I know which IP/hostname the client connect to in node.js TCP Server?

var server = net.createServer(function (stream) { // The server is behind a firewall, how can I know how the client connect to this server? console.log(stream.localAddress); }); server.listen(21, '0.0.0.0');

Thanks

A: 

Got the ans: We can use stream.address() to get the port and host the client connect to.

Eric Fong