title: How to get the client's IP address in Java stream communication
body: <p>I have a Java server program processing clients requests using socket streams. And it works fine.
  However, I need to see the client's IP address on the server side. I see several similar questions here and they all recommend using the <code>getRemoteSocketAddress()</code>  (or <code>getInetAddrees()</code>) method.</p>
  
  <p>Here is an example: </p>
  
  <pre><code>ServerSocket serverSocket_A = new ServerSocket(port1);
  Socket clientSocket_A = serverSocket_A.accept();
  </code></pre>
  
  <p>The program is blocked here listening for a client's request. When the request is received processing continues. And that means that <code>clientSocket_A</code> is already connected to the remote client. </p>
  
  <p>Now, if I issue</p>
  
  <pre><code>requesterAddress = clientSocket_A.getRemoteSocketAddress().toString();
  </code></pre>
  
  <p>it returns this strange address: 0:0:0:0:0:0:0:1 instead of 127.0.0.1 (my client is on the local machine). </p>
  
  <p>Any idea how to resolve this issue? </p>
  
  <p>Interesting, that I also have a <code>ClientSocket_B</code>, set inside this server program, that connects to to the Web Server. Applying the same method for this <code>clientSocket_B</code></p>
  
  <pre><code>Socket clientSocket_B = new Socket(WebServerHost, workPort2);
  clientSocket_B.getRemoteSocketAddress().toString();
  </code></pre>
  
  <p>returns a correct IP address of the WebServer.</p>
  
  <p>Why is this happening?</p>