How can a Node.js Socket Server know which IP or domain that the client connect to?
How can I know which IP/hostname the client connect to in node.js TCP Server?
var server = net.createServer(functio开发者_开发问答n (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
Got the ans: We can use stream.address() to get the port and host the client connect to.
精彩评论