inetd script in python?

Donn Cave donn at u.washington.edu
Mon Mar 1 14:45:33 EST 2004


In article <8ab78660.0402270403.6a36f7f3 at posting.google.com>,
 jan.kesten at web.de (Jan) wrote:
...

> 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).

That's odd - works for me on MacOS X.  This is a Berkeley
UNIX platform, though, and it sounds like you may have a
system there where sockets are a layer on an AT&T STREAMS
network implementation - the `transport endpoint' thing
is my clue on that.  That's one thing to look at - maybe
in that system, socket operations really aren't supported
by whatever TLI module they use with inetd.  Try posix.write
and posix.read instead.  They may work, while Berkeley socket
functions don't.

On the other hand, inetd is really supposed to give you a
unit 0 & 1 that support socket operations, and a platform
that fails to do that would be pretty unpopular, I would
think.  I guess it would have the same effect if socket.fromfd
is not working right on your platform, so that might be
something to look into if you are in a position to do that.

   Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list