Skip to content

fix reuse_addr handling on Windows#353

Merged
Guest0x0 merged 2 commits intomainfrom
windows-reuse-addr
May 7, 2026
Merged

fix reuse_addr handling on Windows#353
Guest0x0 merged 2 commits intomainfrom
windows-reuse-addr

Conversation

@Guest0x0
Copy link
Copy Markdown
Collaborator

@Guest0x0 Guest0x0 commented May 7, 2026

The reuse_addr option for @socket.TcpServer is intended for enabling fast restart of server, ignoring TIME_WAIT connections from the last run of the server. This is currently implemented via SO_REUSEADDR on all platforms. However, on Windows, TIME_WAIT sockets are ignored by default and this behavior is not configurable, so in effect reuse_addr is always true on Windows no matter what we do. Meanwhile, SO_REUSEADDR has completely different meaning on Windows. It is more like SO_REUSEPORT on other systems, and has bad security implications.

This PR no longer emits SO_REUSEADDR on Windows, and document the platform-dependent behavior of reuse_addr more clearly (it has some side effects on MacOS/BSD that cannot be isolated).

@coveralls
Copy link
Copy Markdown

coveralls commented May 7, 2026

Coverage Report for CI Build 254

Coverage remained the same at 78.662%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 4096
Covered Lines: 3222
Line Coverage: 78.66%
Coverage Strength: 60879.18 hits per line

💛 - Coveralls

@Guest0x0 Guest0x0 force-pushed the windows-reuse-addr branch from da11708 to 4f94369 Compare May 7, 2026 08:16
@Guest0x0 Guest0x0 merged commit 0d8742d into main May 7, 2026
17 checks passed
@Guest0x0 Guest0x0 deleted the windows-reuse-addr branch May 7, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants