Permalink
Browse files

set SO_EXCLUSIVEADDRUSER on Windows instead of SO_REUSEADDR

closes #550
  • Loading branch information...
1 parent 83b3882 commit 4e152b54d9b3c43923cb4280dda476eb72dbd644 @minrk minrk committed Jun 28, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 tornado/netutil.py
View
@@ -252,7 +252,10 @@ def bind_sockets(port, address=None, family=socket.AF_UNSPEC, backlog=128):
af, socktype, proto, canonname, sockaddr = res
sock = socket.socket(af, socktype, proto)
set_close_exec(sock.fileno())
- sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+ if os.name == 'nt':
+ sock.setsockopt(socket.SOL_SOCKET, socket.SO_EXCLUSIVEADDRUSE, 1)
+ else:
+ sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
if af == socket.AF_INET6:
# On linux, ipv6 sockets accept ipv4 too by default,
# but this makes it impossible to bind to both

0 comments on commit 4e152b5

Please sign in to comment.