(self)
Connects this websocket and starts the upgrade handshake
        with the remote endpoint.
Connects this websocket and starts the upgrade handshake
        with the remote endpoint.
Connects this websocket and starts the upgrade handshake with the remote endpoint .
def connect(self):
        """
        Connects this websocket and starts the upgrade handshake
        with the remote endpoint.
        """
        if self.scheme == "wss":
            # default port is now 443; upgrade self.sender to send ssl
            self.sock = ssl.wrap_socket(self.sock)

        self.sock.connect((self.host, self.port))

        self.sock.sendall(self.handshake_request)

        response = enc('')
        doubleCLRF = enc('\r\n\r\n')
        while True:
            bytes = self.sock.recv(128)
            if not bytes:
                break
            response += bytes
            if doubleCLRF in response:
                break

        if not response:
            self.close_connection()
            raise HandshakeError("Invalid response")

        headers, _, body = response.partition(doubleCLRF)
        response_line, _, headers = headers.partition(enc('\r\n'))

        try:
            self.process_response_line(response_line)
            self.protocols, self.extensions = self.process_handshake_header(headers)
        except HandshakeError:
            self.close_connection()
            raise

        self.handshake_ok()
        if body:
            self.process(body)
def connect ( self ) : if self . scheme == "wss" : # default port is now 443; upgrade self.sender to send ssl self . sock = ssl . wrap_socket ( self . sock ) self . sock . connect ( ( self . host , self . port ) ) self . sock . sendall ( self . handshake_request ) response = enc ( '' ) doubleCLRF = enc ( '\r\n\r\n' ) while True : bytes = self . sock . recv ( 128 ) if not bytes : break response += bytes if doubleCLRF in response : break if not response : self . close_connection ( ) raise HandshakeError ( "Invalid response" ) headers , _ , body = response . partition ( doubleCLRF ) response_line , _ , headers = headers . partition ( enc ( '\r\n' ) ) try : self . process_response_line ( response_line ) self . protocols , self . extensions = self . process_handshake_header ( headers ) except HandshakeError : self . close_connection ( ) raise self . handshake_ok ( ) if body : self . process ( body )