ios - Is there a way to find pid of a process of socket peer? -


i have following case:

  • two applications (mine , 3rd party) on ios need communicate on tcp/ip
  • i can change code of app, not 3rd party app
  • the protocol can't changed (because can't change 3rd party app).

in app, want make sure talk correct app.

i know how can peer port geetpeername

what looking way figure out pid of process uses port.

i found similar question: how determine pid of peer tcp connection on same ios device? however, in case, both ports in same app.

disclaimer: fine private api. won't sent appstore. however, looking solution non jailbroken phone.

update 1

i said need pid, because there known ways of getting association between pid , application bundle id (using sysctl).

generally speaking, don't care pid per se. concern figure out application on other side of socket.

i don't have solution this, if going try it, proceed in following way:

on unix system, can use lsof command determine processes have files open. includes sockets, , lsof allows determine pid of process using given port. example, use

lsof -n -p -i :443 

if you're trying determine process using port 443 (https), might yield (on os x):

command   pid  user   fd   type             device size/off node name firefox 81615 myname  112u  ipv4 0xffffff8017379a40      0t0  tcp 192.168.2.7:52521->74.125.28.103:443 (close_wait) 

the open source version of lsof darwin, believe, can found here. might try starting main.c, , using command line arguments, navigate through code until find system calls used.

it's possible the calls needed not work when run in process user mobile privileges. but, maybe not? if there's security check inside lsof source itself, can remove that, if copy , paste source yourself.

anyway, might worth try, if no 1 offers answer.

note: lsof available jailbroken phones, , tried running current versions available cydia. did not work me, on 5.1.1 or 6.1.2. not sure why. assume if on repository, though, @ point, able port lsof ios.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -