From 39695e67413938687b8beec671a105bed5d08076 Mon Sep 17 00:00:00 2001 From: chomechome Date: Fri, 2 Feb 2018 21:59:38 +0500 Subject: [PATCH] Create socket in YowNetworkLayer with socket.create_connection function --- yowsup/layers/network/layer.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/yowsup/layers/network/layer.py b/yowsup/layers/network/layer.py index 44b7f8e69..af239cdb2 100644 --- a/yowsup/layers/network/layer.py +++ b/yowsup/layers/network/layer.py @@ -52,9 +52,15 @@ def onDisconnect(self, ev): def createConnection(self): self.state = self.__class__.STATE_CONNECTING - self.create_socket(socket.AF_INET, socket.SOCK_STREAM) - self.out_buffer = bytearray() + endpoint = self.getProp(self.__class__.PROP_ENDPOINT) + + sock = socket.create_connection(endpoint) + sock.setblocking(0) + self.set_socket(sock) + + self.out_buffer = bytearray() + logger.debug("Connecting to %s:%s" % endpoint) if self.proxyHandler != None: logger.debug("HttpProxy connect: %s:%d" % endpoint)