I’ve used the well-known and excellent Knock Knock server tutorial as a way to learn java networking. I have tried to find out the ip address of the connected client using socket.getInetAddress(), but it always returns the ip of my router, 192.168.1.254, presumably because the connection is bouncing through there. Is there any way to get the correct ip of the remote client that’s connected to a tcp socket?
Share
Try this:
it will print whole socket address of the connected client like this: