title: C - Public IP from file descriptor
body: <p>I have three process in three different computers.</p>
  
  <p>Process 1, the client, asks Process 2 for the IP and PORT of Process 3.</p>
  
  <p>Process 3 connected to Process 2 earlier, and Process 2 gets the IP of Process 3 from the file descriptor (Process 3 already knows the ip and port of Process 2).</p>
  
  <p>This works fine, but if I try to run Process 2 and Process 3 in the same computer, the IP of Process 3 is always 127.0.0.1 so Process 1 never finds Process 3.</p>
  
  <pre><code>    socklen_t len;
      struct sockaddr_storage addr;
      char ipstr[INET_ADDRSTRLEN];
  
      len = sizeof addr;
      getpeername(fd, (struct sockaddr*) &amp;addr, &amp;len);
  
      struct sockaddr_in *s = (struct sockaddr_in *) &amp;addr;
  
      inet_ntop(AF_INET, &amp;s-&gt;sin_addr, ipstr, sizeof ipstr);
  </code></pre>
  
  <p>This is the code I'm using, and <strong>ipstr</strong> is the IP I get.</p>
  
  <p>How can I solve this?</p>
  
  <p>Many thanks!</p>