[medusa] Re: Need an example client that does not read from stdin and exits the main loop
Jody Winston
jody@l...
Fri, 18 Jun 1999 08:59:01 -0400 (EDT)
>>>>> "Sam" == Sam Rushing <rushing@n...> writes:
Sam> 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().
Sam> In the __init__ method for you client class, do something
Sam> like this:
Sam> self.push ('200 Go Ahead, Make My Day\r\n')
The problem with my code was that I had forgot to add the terminator.
Sam> You should never use self.send(), because that will bypass
Sam> async_chat's outgoing-buffer scheme. If you push() data even
Sam> before the connection is made, that's ok, it will be sent as
Sam> soon as it does connect. Look at the <monitor> class
Sam> inmonitor.py for an example.
I'll change all my self.send to self.push
>> 2. After all of the commands are sent and all responces
>> processed, how do I exit from the main loop?
Sam> I usually exit by calling asyncore.close_all(), which clears
Sam> out the socket map. This causes asyncore.loop() to exit.
When I was using self.send, calling asyncore.close_all happened before
all the processing was finished on the client side. So I sent the
quit messesage to the server which broke the connection to the client.
Sam> Let me know if you have any other trouble!
------------------------------------------------------------------------
eGroups.com home: http://www.egroups.com/group/medusa
http://www.egroups.com - Simplifying group communications