Python server from inetd?
Tim Roberts
timr at probo.com
Mon Apr 8 22:57:37 EDT 2002
I have a quick little socket server that works OK as a continuously running
app, listening for and handling connections. However, it is a rarely used
service -- only a few times a week -- so it seems silly to have a dedicated
process for it. Thus, I tried to port it to inetd. I cannot seem to make
this work. This is on a RedHat 6.1 Linux system with Python 2.1.
I thought all I needed to do was basically:
#! /usr/bin/python
import socket
client = socket.fromfd( 0, socket.AF_INET, socet.SOCK_STREAM )
while 1:
bfr = client.read(1024)
if not bfr:
break
...
But this does not work. The "read" call returns 0 immediately, over and
over, until the client exits. I never get any data.
In inetd.conf, I used:
nsdc stream tcp nowait root /root/myservice.py myservice
The connection is happening; I can fetch the client IP address and port
number, but I can't read any data.
Suggestions? Anybody have a known-good simple inetd-launched socket
service in Python they could share?
--
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list