Re: inetd script in python?

From: Nick Craig-Wood (ncw_at_axis.demon.co.uk)
Date: 02/27/04


Date: 27 Feb 2004 18:30:03 GMT

Jan <jan.kesten@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@axis.demon.co.uk


Relevant Pages

  • Re: blocking/nonblocking socket and select -> usefull?
    ... setting the socket nonblocking is the only thing that can ... consider the famous Linux inetd denial-of-service ... A sufficiently clever attacker could send a packet to 'inetd' under ...
    (comp.unix.programmer)
  • Re: connection refused
    ... The part where you detach a socket from one thread, ... Can it be expressed as with persistence (inetd, ... proc insok {sok args} { ...
    (comp.lang.tcl)
  • Re: connection refused
    ... The part where you detach a socket from one thread, ... inetd, nowait mode) ... Can it be expressed as with persistence (inetd, ... the init overhead of the execed tclsh ...
    (comp.lang.tcl)
  • Re: inetd script in python?
    ... > manage to get a script working that is started by inetd. ... > So far I read about that I could use stdin and stdout for ... > use socket.fromfd to get a socket object to work with. ... No. inetdwill invoke your script, ...
    (comp.lang.python)
  • Re: inetd script in python?
    ... >> So far I read about that I could use stdin and stdout for ... >> communication since inetd handles the socket. ... >> could use socket.fromfd to get a socket object to work with. ...
    (comp.lang.python)