title: How to retrieve client's IP and PORT on the server socket end?
body: <p>I have a socket listener java based running on the desktop end and I have a mobile client, which is able to connect with this socket server without any issues. I want to have the socket connection established for each client separately, when client is trying to access new connection. I read from this link, <a href="https://stackoverflow.com/questions/2439472/how-the-clients-client-sockets-are-identified">Reference link for multiple connection detection</a></p>
  
  <p>about how socket can differentiate for multiple connections. It is mentioned that based on the Client connection's IP and PORT detected on the socket server and the connection is made unique for each connection. Client PORT will differ for each connection. I read that, we can call <code>getpeername</code> to get the client connection's IP and PORT on the socket server end. But, i couldn't see any such API available in Java and then found the below one.</p>
  
  <pre><code>ServerSocket server = new ServerSocket(8080);
  System.out.println("server.getInetAddress();: " + server.getInetAddress());
  </code></pre>
  
  <p>But, It is returning always <code>server.getInetAddress():- 0.0.0.0/0.0.0.0</code>
  when the mobile client (Simulator) is calling this socket. </p>
  
  <p>Could someone advise me, why I'm not getting the client's IP and PORT using the above InetAddress API on the socket end? Or Do I need to use different approach? </p>