
May 14th, 2004, 10:08 AM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 10
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
TCPServer question
hey,
I'm writing a little query function for a small file search engine and I have a little snag. After I've sent out the queries, I start a SocketServer.TCPServer listening for responses. The responses are coming back via XML-RPC. My problem is that I want to only accept responses for a given period of time after the query is sent out. If I use serve_forever, my client hangs.....if I use handle_request() I can only get 1 repsonse.
My initial solution was to put handle_request inside a while loop which will just check current time against start time and see if its been listening for x seconds or not. However, since handle_request appears to block, if noone responds, or if noone responds near the limited time, then it will just stay hanging waiting for a connection.
Does anyone know of a way around this?? I've started experimenting with socket timeouts but haven't gotten anywhere yet.....if this is going to be the only way to do it, does anyone know of a good online tutorial for this?
Thanks,
|