socket.timeout doesn't seem to do it. Use select instead.