Skip to content

Fix refused Windows TCP connections with a timeout - #3683

Merged
gabime merged 2 commits into
gabime:v1.xfrom
Aurantium-47:fix/windows-tcp-refused-connect
Oct 24, 2026
Merged

gabime merged 2 commits into
gabime:v1.xfrom
Aurantium-47:fix/windows-tcp-refused-connect

Conversation

@Aurantium-47

Copy link
Copy Markdown
Contributor

Windows timed TCP connections currently wait only for writability. Winsock reports a failed nonblocking connection in exceptfds, so a refused connection consumes the entire timeout and is reported as WSAETIMEDOUT instead of WSAECONNREFUSED.

Watch a separate exception set as well, then use the existing SO_ERROR check to return the actual connection error. This follows the Winsock select contract.

Add Windows loopback tests for a bound, non-listening socket and a listening socket. The refusal test checks the error code, with no timing assertion. It fails before the change; the success control passes before and after.

Validation on Windows with MSVC 19.44 and bundled fmt: compiled and header-only unit suites, CMake consumer test, changed-range clang-format and git diff --check passed.

Prepared and validated with OpenAI Codex assistance.

@gabime
gabime merged commit 9af9f48 into gabime:v1.x Oct 24, 2026
13 of 14 checks passed
@gabime

gabime commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Thanks @Aurantium-47

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