Given a filedescriptor, how can I find source IP??

Ed Gould ed at mtxinu.COM
Tue Mar 26 16:41:31 AEST 1991


>Remember boys and girls, "getpeername()" only works on sockets.
>I guess I was not clear - the program does not open a socket -
>it inherits some filedescriptors (0 1 and 2).

A program can inherit sockets, just as it can inherit files.  "File"
descriptors can refer to either.  If you're asking about the child
of a telnet session - which has pseudo-terminals connected to 0,
1, and 2 - then you are out of luck.  In general, there is no way
to track backwards through the descriptor of a pty to its controlling
process and then through one of that processe's descriptors to the
foreign machine.

-- 
Ed Gould                    mt Xinu, 2560 Ninth St., Berkeley, CA  94710  USA
ed at mtxinu.COM		    +1 415 644 0146

"I'll fight them as a woman, not a lady.  I'll fight them as an engineer."



More information about the Comp.unix.wizards mailing list