On Thu, 2002-12-05 at 08:06, Jason R. Mastaler wrote:
> David Guerizec <[EMAIL PROTECTED]> writes:
> 
> > To keep things simple, a line oriented protocol will do.
> 
> Perhaps use asyncore/asynchat?

I didn't think about it, let's read the doc...

> asynchat is now documented in the devel version of the documentation.
> It wasn't available when I wrote tmda-ofmipd, so I had to read the
> source to learn how it worked. :-/
> 
> http://www.python.org/dev/doc/devel/lib/module-asyncore.html
> http://www.python.org/dev/doc/devel/lib/module-asynchat.html

mmh, it seems asyncore/asynchat only use sockets, not file descriptors.
I've already made a prototype server, that simply reads on stdin and
writes on stdout. From that, I've derived it to map sys.std* to a
socket.
This design allows me several modes of operation:

1. console mode: without socket, run from a terminal in interactive mode
    Very practical to debug the parser/interpreter. Can also be used by
    shell scripts, for example to automate certain actions not available
    from tmda-*

2. inetd mode: without direct socket, run from inetd
    Less resource waste, but loss in speed at connect.

3. daemon mode: with socket, bind to a port and fork after auth
    Better performance IMHO, cause there is no need to fire up a new
    python interpreter for each connection, there is "only" the fork
    overhead.

Correct me if I'm wrong, but from what I've read in the doc and the
source, only the daemon mode can be implemented with asyncore/asynchat.

For the moment, I think I'll keep my design, if in the future we find we
don't need console and inetd mode, I still could change it for
asyncore/asynchat.

David
_________________________________________________
tmda-workers mailing list ([EMAIL PROTECTED])
http://tmda.net/lists/listinfo/tmda-workers

Reply via email to