inetd script in python?

Jan jan.kesten at web.de
Fri Feb 27 07:03:31 EST 2004


Hi all!

I looked around a lot, but I didn't find a solution. I have to write
an simple server application to do some jobs and return a result to a
client. I tried SocketServer and this works really fine. But I didn't
manage to get a script working that is started by inetd.

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.

Is there any working example out there - I coudn't find one. There was
just a snippet like this:

import socket
import sys
client = socket.fromfd(sys.stdin.fileno(), socket.AF_INET,
socket.SOCK_STREAM )
while 1:
    bfr = client.recv(1024)
    client.send(bfr)

And a similar one with 0 instead of sys.stdin.fileno(). Only thing I
get is this error:

socket.error: (134, 'Transport endpoint is not connected')

(Same thing when using stdin/stdout - I'm trying to connect via a
telnet client on a Solaris8/sparc machine).

Any hints?
Jan



More information about the Python-list mailing list