Skip to content

Commit

Permalink
Fix bind_sockets if OS does not support IPv6
Browse files Browse the repository at this point in the history
  • Loading branch information
schlamar committed Jun 11, 2013
1 parent 3638ce4 commit be65543
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tornado/netutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ def bind_sockets(port, address=None, family=socket.AF_UNSPEC, backlog=128, flags
for res in set(socket.getaddrinfo(address, port, family, socket.SOCK_STREAM,
0, flags)):
af, socktype, proto, canonname, sockaddr = res
sock = socket.socket(af, socktype, proto)
try:
sock = socket.socket(af, socktype, proto)
except socket.error as e:
if e.args[0] == errno.EAFNOSUPPORT:
continue
raise
set_close_exec(sock.fileno())
if os.name != 'nt':
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
Expand Down

0 comments on commit be65543

Please sign in to comment.