inetd script in python?

Nick Craig-Wood ncw at axis.demon.co.uk
Fri Feb 27 13:30:03 EST 2004


Jan <jan.kesten at web.de> wrote:
>  So far I read about that I could use stdin and stdout for
>  communication since inetd handles the socket. And I read that I
>  could use socket.fromfd to get a socket object to work with. But
>  both do not work, I tried to send just a greeting back to the
>  client or getting some text - nothing.

You should find something simple like this works - inetd is supposed
to make writing internet daemons easy!

import sys

while 1:
    bfr = sys.stdin.read(1024)
    sys.stdout.write(bfr)

You can then test the code on the command line by typing stuff to it
and seeing it print its output.

Beware buffering though!

-- 
Nick Craig-Wood
ncw at axis.demon.co.uk



More information about the Python-list mailing list