catch "address family not supported" errors when sending files. Fixes #5327

This commit is contained in:
Alex V. Myltsev 2010-01-02 22:47:36 +01:00
parent 1d0c57915a
commit 0699e2e3a1
1 changed files with 8 additions and 2 deletions

View File

@ -861,7 +861,13 @@ class Socks5Listener(IdleObject):
def bind(self): def bind(self):
for ai in self.ais: for ai in self.ais:
# try the different possibilities (ipv6, ipv4, etc.) # try the different possibilities (ipv6, ipv4, etc.)
try:
self._serv = socket.socket(*ai[:3]) self._serv = socket.socket(*ai[:3])
except socket.error, e:
if e.errno == EAFNOSUPPORT:
self.ai = None
continue
raise
self._serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self._serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self._serv.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) self._serv.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
self._serv.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) self._serv.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)