multi command session through a socket

Gordon McMillan gmcm at hypernet.com
Fri Oct 12 14:28:02 CEST 2001


Nomad wrote:

> 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).

[snip]

>     def handle(self):

[snip]

>      self.quit = 1
>      while self.quit == 1: # <---- what is wrong here
>           self.raw_requestline = self.rfile.readline()
>           if not self.parse_request():
>                return
>           
>     def parse_request(self):  

[snip]

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 
implementations.

- Gordon



More information about the Python-list mailing list