def __init__(self, socketIO_session, is_secure, base_url, **kw): super(_WebsocketTransport, self).__init__() url = '%s://%s/websocket/%s' % ( 'wss' if is_secure else 'ws', base_url, socketIO_session.id) try: self._connection = websocket.create_connection(url) except socket.timeout as e: raise ConnectionError(e) except socket.error as e: raise ConnectionError(e) self._connection.settimeout(TIMEOUT_IN_SECONDS)
def __init__(self): """ Initialize the sending and receiving parts. """ sockopt = ((socket.IPPROTO_TCP, socket.TCP_NODELAY, DEACTIVATE_NAGLE), # quickack does not really make a difference #(socket.IPPROTO_TCP, socket.TCP_QUICKACK, 0), ) self.ws = websocket2.create_connection(ADDR, sockopt=sockopt) print 'opened websocket' self.running = True self.sent_messages = {} self.measuring_counter = MEASURE_FREQ self.recver = threading.Thread(target=self.do_recv) self.recver.daemon = True
def __init__(self): """ Initialize the sending and receiving parts. """ sockopt = ( (socket.IPPROTO_TCP, socket.TCP_NODELAY, DEACTIVATE_NAGLE), # quickack does not really make a difference #(socket.IPPROTO_TCP, socket.TCP_QUICKACK, 0), ) self.ws = websocket2.create_connection(ADDR, sockopt=sockopt) print 'opened websocket' self.running = True self.sent_messages = {} self.measuring_counter = MEASURE_FREQ self.recver = threading.Thread(target=self.do_recv) self.recver.daemon = True