7

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');

1 Answer 1

7
  1. http://nodejs.org/docs/v0.3.2/api/net.html#stream.remoteAddress

  2. Yes

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, works perfectly. What is the best way to find info like this? There isn't a whole lot on google- albeit I was probably not entering the correct keywords.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.