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');
http://nodejs.org/docs/v0.3.2/api/net.html#stream.remoteAddress
Yes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With