TCPsocket.connect expanded; ssl.wrap_socket used for Python >= 2.6