Skip to content

Preserve socket errors in connection failure diagnostics - #645

Merged
bsergean merged 3 commits into
masterfrom
fix/connect-error-reporting
Nov 17, 2026
Merged

bsergean merged 3 commits into
masterfrom
fix/connect-error-reporting

Conversation

@bsergean

@bsergean bsergean commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Failed nonblocking connects can report stale or zero errors. Query SO_ERROR for write readiness on Windows and POSIX, preserve a failing getsockopt() error, and save the error before closing the descriptor. Format native errors through std::system_category() so Winsock errors receive the correct description. Also compare socket handles against their correctly typed invalid value.

Refs #543. This addresses misleading diagnostics; the original application's connection failure still needs its own current reproducer.

Validation: immediate invalid-handle regression test; connection/reconnect tests pass; full plain-socket suite 28/28 passed. C++11 warnings-as-errors build and MinGW compilation checks passed (an unrelated pre-existing unused-parameter warning is suppressed in the direct cross-compile check). The refused-loopback test was removed because Windows TCP retries make it slow. Changed C++ formatted; git diff --check passed.

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.

1 participant