Skip to content

Commit 5685c85

Browse files
authored
Merge pull request #1108 from esnyder/trio-928
Drop usage of SO_EXCLUSIVEADDRUSE on win32 (#928)
2 parents ffd490f + 6449937 commit 5685c85

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

newsfragments/928.misc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
On win32 we no longer set SO_EXCLUSIVEADDRUSE when binding a socket in :exc:`trio.open_tcp_listeners`.

trio/_highlevel_open_tcp_listeners.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,7 @@ async def open_tcp_listeners(port, *, host=None, backlog=None):
120120
raise
121121
try:
122122
# See https://github.com/python-trio/trio/issues/39
123-
if sys.platform == "win32":
124-
sock.setsockopt(
125-
tsocket.SOL_SOCKET, tsocket.SO_EXCLUSIVEADDRUSE, 1
126-
)
127-
else:
123+
if sys.platform != "win32":
128124
sock.setsockopt(
129125
tsocket.SOL_SOCKET, tsocket.SO_REUSEADDR, 1
130126
)

trio/tests/test_highlevel_open_tcp_listeners.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ async def test_open_tcp_listeners_rebind():
122122
sockaddr1 = l1.socket.getsockname()
123123

124124
# Plain old rebinding while it's still there should fail, even if we have
125-
# SO_REUSEADDR set (requires SO_EXCLUSIVEADDRUSE on Windows)
125+
# SO_REUSEADDR set
126126
probe = stdlib_socket.socket()
127127
probe.setsockopt(stdlib_socket.SOL_SOCKET, stdlib_socket.SO_REUSEADDR, 1)
128128
with pytest.raises(OSError):

0 commit comments

Comments
 (0)