Fix HTTPServer on windows, where IPPROTO_IPV6 options are not available

This commit is contained in:
Ben Darnell 2011-05-28 13:40:38 -07:00
parent 50c2e49bf0
commit 298a438de8
1 changed files with 4 additions and 1 deletions

View File

@ -196,7 +196,10 @@ class HTTPServer(object):
# separate sockets *must* be used to listen for both ipv4
# and ipv6. For consistency, always disable ipv4 on our
# ipv6 sockets and use a separate ipv4 socket when needed.
sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
#
# Python 2.x on windows doesn't have IPPROTO_IPV6.
if hasattr(socket, "IPPROTO_IPV6"):
sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
sock.setblocking(0)
sock.bind(sockaddr)
sock.listen(128)