-->
Page 1 of 1

how to know IP from tcp connection?

PostPosted: Tue Mar 10, 2015 9:17 pm
by Vitoa
Hi, how can I print the iP from a connection?
conn:on("receive", function(conn, pl) end end)

Regards,
Vito

Re: how to know IP from tcp connection?

PostPosted: Wed Mar 11, 2015 3:42 am
by ProfePaco
If you mean the IP of the "sender"... why not the sender sends its IP itself?

Re: how to know IP from tcp connection?

PostPosted: Wed Mar 11, 2015 12:17 pm
by Vitoa
Hi, the client does not to need to send the IP, because the IP is sent in a lower layer from TCP connection.
For example in nodejs u have this way to catch the IP from sender sock.remoteAddress

server.on('connection', function(sock) {
console.log('Client connected from ' + sock.remoteAddress);
// Client address at time of connection ----^
});


But here in nodemcu
conn:on("receive", function(conn, pl) end end)

pl is payload, and conn should contain connection related variables
whiche elements contains conn?


Any help is welcome

Regards,
Vitor