Skip to content

fix(driver,iocp): report Winsock error codes for socket operations - #1146

Open
lexoliu wants to merge 1 commit into
compio-rs:masterfrom
lexoliu:fix/iocp-socket-winsock-errors
Open

lexoliu wants to merge 1 commit into
compio-rs:masterfrom
lexoliu:fix/iocp-socket-winsock-errors

Conversation

@lexoliu

@lexoliu lexoliu commented Nov 11, 2026

Copy link
Copy Markdown

Fixes #1145

Socket operations on the IOCP driver now report Winsock error codes. OpCode gains completion_error, a no-op by default, which the driver calls on a failed completion. The socket ops (and the managed ops wrapping them) override it to ask WSAGetOverlappedResult for the provider's error. Cancellation keeps ERROR_OPERATION_ABORTED, so cancel detection is unchanged.

With that, a refused connect is ConnectionRefused, and an ICMP port unreachable on UDP is WSAECONNRESET. compio-quic no longer needs its ERROR_PORT_UNREACHABLE arm.

Adds connect_refused to compio-net/tests/tcp_connect.rs.

A failed completion carries an NTSTATUS, which the driver converts to a
Win32 code. For a socket that is not what a Winsock call reports: a
refused connect comes back as ERROR_CONNECTION_REFUSED (1225) instead of
WSAECONNREFUSED, and io::Error::kind() calls it Uncategorized. Socket
operations now resolve the error through WSAGetOverlappedResult, so a
refused connect is ConnectionRefused and an ICMP port-unreachable on a UDP
socket is ConnectionReset, as with mio.
@github-actions github-actions Bot added bug Something isn't working driver: iocp About the IOCP driver package: driver Related to compio-driver labels Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working driver: iocp About the IOCP driver package: driver Related to compio-driver

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IOCP socket operations report Win32 error codes, so a refused connect is not ConnectionRefused

1 participant