I have two questions:
1) How can I get the IP address, and any other possible data about the client when it connects (see comment in code in the connect section)
2) Will this code safely allow multiple client connections at the same time?
var net = require('net');
var sys = require('sys');
var server = net.createServer(function (stream) {
stream.setEncoding('utf8');
stream.on('connect', function() {
///////////////////////////////////////////////////////
console.log("WANT THE IP OF THE CONNECTOR HERE!!!!!!");
///////////////////////////////////////////////////////
});
// data recieve
stream.on('data', function (data) {
//stream.write(data);
console.log("recv: [" + data + "]");
});
// end connection
stream.on('end', function () {
stream.end();
});
});
server.listen(50505, 'localhost');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.