[medusa] Need an example client that does not read from stdin and exits the main loop

Sam Rushing rushing@n...
Thu, 17 Jun 1999 09:33:01 -0700 (PDT)


jody@s... writes:
> I've written a server in medusa that works like ftp. That is:
> command space args
> and the server responds with: 
> code space results
> 
> This code works using telnet and using a medusa client that reads
> from stdin. My questions are:
> 
> 1. How do I send a fixed set of commands to the server from a
> client? What I have tried and failed with is in the client's
> handle_connect to use self.send().

In the __init__ method for you client class, do something like this:

self.push ('200 Go Ahead, Make My Day\r\n')

You should never use self.send(), because that will bypass
async_chat's outgoing-buffer scheme. If you push() data even
before the connection is made, that's ok, it will be sent as soon
as it does connect. Look at the <monitor> class inmonitor.py for
an example.

> 2. After all of the commands are sent and all responces
> processed, how do I exit from the main loop?

I usually exit by calling asyncore.close_all(), which clears out
the socket map. This causes asyncore.loop() to exit.

Let me know if you have any other trouble!

-Sam


------------------------------------------------------------------------

eGroups.com home: http://www.egroups.com/group/medusa
http://www.egroups.com - Simplifying group communications