views:

34

answers:

1

I want to use server.get_request() to receive requests, but I want it to timeout after 500 milliseconds. Is this correct? Doesn't seem to work... thanks.

class UDPServer(SocketServer.BaseRequestHandler):
    timeout = .500

if __name__ == "__main__":
    server = SocketServer.UDPServer(('localhost', '12345'), UDPServer)
    server.get_request()
+1  A: 

I feel there are some places wrong: 1. The class derived from SocketServer.BaseRequestHandler should be MyUDPServerHandler or something else, but should not be UDPServer which is a built-in class in SocketServer 2. It should be " server = SocketServer.UDPServer(('localhost', '12345'), MyUDPServerhandler) 3. Then maybe it should be server.timeout = .500. And define a handle_timeout() method

xueyumusic
You are right about the naming convention. I overlooked that. Surprisingly, this was not causing any trouble. But I see, it's just a variable, accessible via the dot operator. I didn't understand how to set it. Thanks.
Brian D