One more socket programming question

John Salerno johnjsal at NOSPAMgmail.com
Wed Jun 18 09:59:27 EDT 2008


"Tim Roberts" <timr at probo.com> wrote in message 
news:sjdh541b2u7m789i8ef6rmple5smklbt9i at 4ax.com...
> John Salerno <johnjsal at gmailNOSPAM.com> wrote:
>>
>>I'm now experimenting with the SocketServer class. Originally I
>>subclassed the StreamRequestHandler to make my own custom handler, but a
>>result of this seems to be that the client socket closes after it has
>>been used, instead of staying open.
>
> Right.  "handle" is not called for one REQUEST at a time, it's called for
> one CONNECTION at a time.  If you need a connection to be persistent, then
> your handle() function needs to sit in a loop making recv calls until you
> detect that the conversation is complete.

Ah, so I need to rewrite my handle method. I was thinking that the 
specialized setup() and/or finish() calls from StreamRequestHandler were the 
reason that the connection was closed after one use (which is why I tried 
BaseRequestHandler instead).

Thanks. 





More information about the Python-list mailing list