title: socket.connect() does not throw an exception when nothing bound to host?
body: <p>Trying to connect to a TCP socket, but have had weird disconnect/reconnect issues. I have stopped anything running on the port user <code>fuser -k PORT/tcp</code>, but still see that socket.connect() returns successfully.</p>
  
  <p>Could anyone shed some light as to why this would not throw an Exception on connect()?</p>
  
  <pre><code>SERVER_IP = '... an ip address of a real apache server, nothing bound to 2000'
  PORT = 2000
  new_socket = socket.socket()
  new_socket.settimeout(4.0)
  try:
      new_socket.connect((SERVER_IP, PORT))
  except Exception as e:
      print('unable to connect')
      return # EXPECTED TO RETURN HERE
  else:
      new_byte = new_socket.recv(1)
      if len(new_byte) == 0:
          print('empty!') # GET HERE
  </code></pre>
  
  <p>The socket docs suggest that receiving a empty response (<code>len() == 0</code>) back would indicate that the host is saying that <a href="http://man7.org/linux/man-pages/man2/recv.2.html" rel="nofollow noreferrer">it will not send any additional information</a>, but if there's not a TCP socket being hosted on that port, I don't know how that code would ever be reached.</p>