def connect(self): # resolve addresses manually for compatibility with Python 2.5 # which doesn't support create_connection exc = socket.gaierror(-2, 'Name or service not known') for ai in socket.getaddrinfo(self._host, self._port, socket.AF_UNSPEC, socket.SOCK_STREAM): try: exc = None self._sock = socket.socket(ai[0], ai[1], ai[2]) self._sock.settimeout(30) self._sock.connect(ai[4]) break except socket.error as e: exc = e if exc != None: raise exc self._sock.settimeout(600) XmppStream.connect(self)
def starttls_proceed(self, elem): self._sock = ssl.wrap_socket(self._sock, do_handshake_on_connect=False) self._sock.do_handshake() XmppStream.connect(self)
def connect(self): self._sock = socket.create_connection((self._host, self._port)) XmppStream.connect(self)