Set timeout for connection
This commit is contained in:
parent
d89d770e73
commit
87503b875a
1 changed files with 4 additions and 0 deletions
|
@ -127,6 +127,8 @@ class Connection(object):
|
|||
if "TCP_NODELAY" in dir(socket):
|
||||
self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||
|
||||
timeout_before = self.sock.gettimeout()
|
||||
self.sock.settimeout(30)
|
||||
self.sock.connect((self.ip, int(self.port)))
|
||||
|
||||
# Implicit SSL
|
||||
|
@ -150,6 +152,8 @@ class Connection(object):
|
|||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.sock.connect((self.ip, int(self.port)))
|
||||
|
||||
self.sock.settimeout(timeout_before)
|
||||
|
||||
# Detect protocol
|
||||
self.send({"cmd": "handshake", "req_id": 0, "params": self.getHandshakeInfo()})
|
||||
event_connected = self.event_connected
|
||||
|
|
Loading…
Reference in a new issue