summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2004-07-15 16:17:07 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2004-07-15 16:17:07 (GMT)
commit5336f8caa4ed6d3777183f8b0ab1fc81db3eec3d (patch)
tree5de8c80ae403d2e8f37cde5075ed657a76aa431c
parent7323f084229266bc000d4d6c1c2b7e73bcc11c13 (diff)
downloadcpython-5336f8caa4ed6d3777183f8b0ab1fc81db3eec3d.zip
cpython-5336f8caa4ed6d3777183f8b0ab1fc81db3eec3d.tar.gz
cpython-5336f8caa4ed6d3777183f8b0ab1fc81db3eec3d.tar.bz2
[Patch #982681] Apply this patch correctly; makes set_reuse_addr() work on Windows
-rw-r--r--Lib/asyncore.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/asyncore.py b/Lib/asyncore.py
index f63a83e..5f60219 100644
--- a/Lib/asyncore.py
+++ b/Lib/asyncore.py
@@ -263,14 +263,20 @@ class dispatcher:
def set_reuse_addr(self):
# try to re-use a server port if possible
try:
+ # Windows SO_REUSEADDR is very broken (from a unixy perspective)
+ if sys.platform == 'win32':
+ reuse_constant = socket.SO_EXCLUSIVEADDRUSE
+ else:
+ reuse_constant = socket.SO_REUSEADDR
+
self.socket.setsockopt(
- socket.SOL_SOCKET, socket.SO_REUSEADDR,
+ socket.SOL_SOCKET, reuse_constant,
self.socket.getsockopt(socket.SOL_SOCKET,
- socket.SO_REUSEADDR) | 1
+ reuse_constant) | 1
)
except socket.error:
pass
-
+
# ==================================================
# predicates for select()
# these are used as filters for the lists of sockets