This is kind of a programming question, but it's very Linux/Unix specific. If I get a TCP connection from localhost, is there a simple way to tell which user made the connection inside a C program without shelling out? I know this isn't too hard with a Unix domain socket.
I already know the remote IP address is localhost (::1 or 127.0.0.1) and I know the remote port number. What I don't know is the effective user id of the process that made the connection. Is there any way to discover this?