0

I've built a client server application. How can I get the client IP on the serverside? I already used "socket.getRemoteSocketAddress()" but this gives an internal IP.

  • As in the public id? https://stackoverflow.com/questions/2939218/getting-the-external-ip-address-in-java#2939223 has a solution for that. – Danny Piper Sep 05 '19 at 20:22
  • Thank you two. I found out that it wasn't working because of the firewall configuration, the code itself was good. Problem is solved :) –  Sep 05 '19 at 20:46

1 Answers1

1

When you start to listen with serverSocket.accept(); and you store the Socket returning object of this function, you can get the client ip with this function from the socket with this: socket.getInetAddress().getHostAddress();.

Rgld_
  • 26
  • 1
  • Thank you! I found out that it wasn't working because of the firewall configuration, the code itself was good. Problem is solved :) –  Sep 05 '19 at 20:46