Merge branch 'master' of https://github.com/cjhanks/websocket-client into cjhanks-master
This commit is contained in:
@@ -47,6 +47,7 @@ else:
|
|||||||
from base64 import encodestring as base64encode
|
from base64 import encodestring as base64encode
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import errno
|
||||||
import struct
|
import struct
|
||||||
import uuid
|
import uuid
|
||||||
import hashlib
|
import hashlib
|
||||||
@@ -418,7 +419,8 @@ class WebSocket(object):
|
|||||||
if not addrinfo_list:
|
if not addrinfo_list:
|
||||||
raise WebSocketException("Host not found.: " + hostname + ":" + str(port))
|
raise WebSocketException("Host not found.: " + hostname + ":" + str(port))
|
||||||
|
|
||||||
family = addrinfo_list[0][0]
|
for addrinfo in addrinfo_list:
|
||||||
|
family = addrinfo[0]
|
||||||
self.sock = socket.socket(family)
|
self.sock = socket.socket(family)
|
||||||
self.sock.settimeout(self.timeout)
|
self.sock.settimeout(self.timeout)
|
||||||
for opts in DEFAULT_SOCKET_OPTION:
|
for opts in DEFAULT_SOCKET_OPTION:
|
||||||
@@ -426,8 +428,18 @@ class WebSocket(object):
|
|||||||
for opts in self.sockopt:
|
for opts in self.sockopt:
|
||||||
self.sock.setsockopt(*opts)
|
self.sock.setsockopt(*opts)
|
||||||
# TODO: we need to support proxy
|
# TODO: we need to support proxy
|
||||||
address = addrinfo_list[0][4]
|
address = addrinfo[4]
|
||||||
|
try:
|
||||||
self.sock.connect(address)
|
self.sock.connect(address)
|
||||||
|
except socket.error as error:
|
||||||
|
if error.errno in (errno.ECONNREFUSED, ):
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise error
|
||||||
|
|
||||||
if proxy_host:
|
if proxy_host:
|
||||||
self._tunnel(hostname, port)
|
self._tunnel(hostname, port)
|
||||||
|
Reference in New Issue
Block a user