inetd script in python?

William Park opengeometry at yahoo.ca
Fri Feb 27 22:31:52 EST 2004


Jan <jan.kesten at web.de> wrote:
> 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 )

No.  inetd(8) will invoke your script, with stdin/stdout/stderr attached
to incoming connection.  It will take care of all socketing.  And, all
you have to do is read from stdin and write to stdout/stderr.

You can skim over 
    http://home.eol.ca/~parkw/index.html#httpd
for an example of inetd daemon script.  It's shell script, but Python
script would go similar way.

-- 
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
Linux solution for data management and processing. 



More information about the Python-list mailing list