Skip to content

Commit

Permalink
handle OSError errno 97 when ipv6 is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
PierluigiGreto committed May 8, 2018
1 parent 46367ea commit 586f5cc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sshutil/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,12 @@ def __init__(self,
# Bind first to IPv6, if the OS supports binding per AF then the IPv4
# will succeed, otherwise the IPv6 will support both AF.
for pname, host, proto in [("IPv6", '::', socket.AF_INET6), ("IPv4", '', socket.AF_INET)]:
protosocket = socket.socket(proto, socket.SOCK_STREAM)
try:
protosocket = socket.socket(proto, socket.SOCK_STREAM)
except OSError as e:
if e.errno == errno.EAFNOSUPPORT:
continue
raise
protosocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
if self.debug:
logger.debug("Server binding to proto %s port %s", str(pname), str(port))
Expand Down

0 comments on commit 586f5cc

Please sign in to comment.