SIGCHLD, fork, listen

Bill Eldridge bill at hk.rfa.org
Sat Sep 25 13:25:01 EDT 1999


Donn Cave wrote:
> Quoth Bill Eldridge <bill at hk.rfa.org>:
> | Another option would be to use inetd, but I need to
> | do some host/address verification, and couldn't figure
> | out how to latch onto that kind of socket info from
> | a new spawned inetd handler using Python.  Ideas?

> Would this work?
> 
>     sock = socket.fromfd(0)
>     print sock.getpeername()
> 
> inetd should give you the socket descriptor on unit 0.

Yep, works beautifully, thanks.

I knew I was getting the socket on file descriptor 0,
but didn't see how to treat the fd as a socket - this
function does it for me.  BTW, it needs to be:

    sock = socket.fromfd(0,AF_INET,SOCK_STREAM)

or whatever protocol is appropriate.

Bill

--
Bill Eldridge
Radio Free Asia
bill at rfa.org




More information about the Python-list mailing list