in reply to Threaded sockets, etc.

You could set an alarm(200) and break away from the infinite while loop; changing the 200 secs to whatever you think fit for a timeout?