title: Is there a way to find pid of a process of socket peer?
body: <p>I have the following case:</p>
  
  <ul>
  <li>Two applications (mine and 3rd party) on iOS need to communicate over TCP/IP</li>
  <li>I can change the code of my app, but not the 3rd party app</li>
  <li>The protocol can't be changed (because I can't change the 3rd party app).</li>
  </ul>
  
  <p>In my app, I want to make sure that I talk to the correct app.</p>
  
  <p>I know how I can get peer port with <a href="http://www.beej.us/guide/bgnet/output/html/multipage/getpeernameman.html" rel="nofollow noreferrer">geetpeername</a></p>
  
  <p>What I am looking for is a way to figure out the pid of the process which uses this port.</p>
  
  <p>I found similar question: <a href="https://stackoverflow.com/questions/8248028/how-do-you-determine-the-pid-of-a-peer-tcp-connection-on-the-same-ios-device#comment23631276_8248028">How do you determine the PID of a peer TCP connection on the same iOS device?</a>
  However, in his case, both ports are in the same app.</p>
  
  <p>Disclaimer: I am fine with private API. It won't be sent to AppStore. However, I am looking for a solution for non a jailbroken phone.</p>
  
  <p><strong>Update 1</strong></p>
  
  <p>I said that I need PID, because there are known ways of getting association between PID and application bundle id (using sysctl). </p>
  
  <p>Generally speaking, I don't care about PID per se. My concern is figure out what is the application on other side of the socket. </p>