multi command session through a socket
nomad*** at ***freemail.absa.co.za
Fri Oct 12 16:11:48 CEST 2001
On 12 Oct 2001 12:28:02 GMT, Gordon McMillan <gmcm at hypernet.com>
>> I've been playing with sockets and serversockets in Python (2.1 win32)
>> for the last few days. I've been trying to adapt the code from
>> 'BaseHTTPServer.py' in the standard library, but no matter what I try,
>> the server side always drops the connection after only one command,
>> whereas I'd like to be able to run several commands (like telnetting
>> into a pop3 session) and finishing with a QUIT command (or hopfully
>> later a timeout, but that's another question entirely).
>> def handle(self):
>> self.quit = 1
>> while self.quit == 1: # <---- what is wrong here
>> self.raw_requestline = self.rfile.readline()
>> if not self.parse_request():
>> def parse_request(self):
>A cursory examination reveals that you
>are always returning a false value
>from parse_request. Looks like "self.quit"
>and the return from parse_request have
>redundant intents and conflicting
Thanks Gordon, I didn't spot that - looks like I left too much of the
original code in.
I removed the return 0's from parse_request() and changed the handle()
# start test code
self.quit = 1
while self.quit == 1:
self.raw_requestline = self.rfile.readline()
# end test code
and it keeps alive until I give a 'quit' command. All I have to do
now is work out how to implement a decent timeout function.
Wondering of the vast emptyness of the 'net
in search of something cool.
More information about the Python-list