Reputation: 13947
For reasons I'd rather not go into (has to do with compatibility with a third-party library that I cannot change), I need to use a TCP socket to do IPC within a single process in iOS.
In order to prevent other processes from talking to my TCP IPC socket, I'd like to verify with the OS that the process calling connect()
(from another thread) has the same PID as my own.
On OS X I noticed that netstat
does not have this information (unlike other OSes such as Windows and Linux) and the only way I was able to determine this information was using lsof
. I am not sure what might be available in the iOS sandbox, but so far it seems like my best bet (even though it seems expensive) is to figure out what lsof
is doing and try to replicate that.
Does anyone know of a system call I can use in order to check this? I've already read through getsockopt(2)
and don't see anything that applies, and I can't find documentation about what ioctl(2)
calls are supported.
What might be possible here?
Upvotes: 0
Views: 825
Reputation: 204926
Wow, that sounds like a terrible API for an in-process library.
getpeername
on the receiving end should match getsockname
of the sending end. You could try to match it up with all open fds in the local process.
Upvotes: 1