Getting TCPClient IP and PORT

Hello.

After your help, mainly with my blocking receive, I have my code working fine, including communication with an Android client, a nice TFT display and some colourful leds :smile:

I would like to display the IP address and port from where the client connects, but taking a look at the TCPClient class I do not see any method to obtain them. Are there such methods in the TCPClient class or any workaround to get them?

Thank you again.
Regards,
Germán

As far as I have seen -and used- WiFi gives my own IP, not the one from the client connecting

Opps i have mistaken :D. That i have no clue.

Hi @mermaja

You must be talking about TCPServer, not TCPClient since with client you are initiating the connection with the remote IP address and port number–you must know these numbers (or hostname) in order to connect to the remote host.

With server you are listening for connections on a particular port at your IP address and when a host connects, you might want to know it’s IP address. The server available() method hands you back a client that is connected to the remote host which might be why you are thinking it is client that could have the method, but I think server would be a better choice.

There are no public methods to get this IP address right but you could file a github issue to add this as a new feature.

1 Like

I agree that it would make more sense in the TCPServer class, but the fact is that it does not exist in any class.

Thank you for your help.

Regards,
Germán.