I'm learning to use sockets in python and something weird is happening. 
I call socket.connect in a try block, and typically it either completes and I have a new socket connection, or it raises the exception.  Sometimes, however, it just hangs.
I don't understand why sometimes it returns (even without connecting!) and other times it just hangs.  What makes it hang?
I am using blocking sockets (non-blocking don't seem to work for connect...), so I've added a timeout, but I'd prefer connect to finish without needing to timeout.
Perhaps, when it doesn't hang, it receives a response that tells it the requested ip/port is not available, and when it does hang there is just no response from the other end?
I'm on OSX10.8 using python2.7
When connect() hangs it is usually because you connect to an address that is behind a firewall and the firewall just drops your packets with no response. It keeps trying to connect for around 2 minutes on Linux and then times out and return an error.
Python socket.connect hangs sometimes