title: C socket get IP address from filedescriptor returned from accept
body: <p><strong>I know this question seems typical</strong> and multiple times answered but I think if you read the details it is not so common (I did not find it).</p>
  
  <p>The point is that I am developing a <strong>unix service in c that opens a socket</strong> and waits for connections, when I have a connection I <strong>create a new process to treat it</strong>, so there can be <strong>multiple connections opened at the same time</strong>.</p>
  
  <pre><code>int newfd = accept(sockfd, (struct sockaddr *)&amp;clientaddr, (socklen_t*)&amp;clientaddr_size);
  </code></pre>
  
  <p>Later on (<strong>after and inside some other methods</strong> and code) <strong>the child process</strong> save the connection information to the BBDD and I need also, <strong>in that precise moment</strong>, to <strong>get the IP address</strong> that opened that connection being treated.</p>
  
  <p>As there can be <strong>multiple connections at the same time</strong> and the <strong>variable <code>struct sockaddr_in clientaddr</code></strong> that I pass to the accept method is <strong>shared for all the process</strong> I am not sure that later on is a good idea to get the IP address information from that way because then <strong>I could get the IP address from another connection opened</strong>.</p>
  
  <p>I would like to be able to <strong>access the IP address from the file descriptor <code>int newfd</code> that I get from the accept method</strong> (the returned integer). Is it possible? Or I misunderstood the file descriptor function?</p>