ulyssessPax:
When you connect
/accept
to/from a device via TCP sockets, you have the following method from that socket:
socket.getRemoteSocketAddress().toString()
it gives you the remote IP address and the port number where it's connected. For example: 192.168.1.30:6000
socket.getLocalSocketAddress()
it gives you the local IP address and the port number where it has established the connection. For example: 10.0.2.15:54471
Hope it's what you're looking for.