I'm have a tracer process that traces a network application.
Given a socket file descriptor belonging to the tracee, would it be possible for the tracer to find the IP it corresponds to(in the case of a server the IP of the interface it binds to, in the case of a client the address of the interface used to make the connection), the port number and the type of connection? Are there libc APIs that could be used to make this work? Any information in /proc
that could be used?
Also, would there be a way to distinguish a file descriptor that corresponds to a socket from one that corresponds to an open file or device?