Repository navigation
Emulate socketPair with TCP over loopback on Windows - #630
Merged
Merged
Conversation
On Windows, AF_UNIX misses a peer's close which races a recv entering its wait, and the recv waits for ever. This happens with blocking, overlapped and IOCP receives alike, but never over TCP. The temporary file the AF_UNIX pair left behind goes too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kazu-yamamoto
added a commit
to kazu-yamamoto/network
that referenced
this pull request
Nov 4, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows,
socketPairemulatessocketpair()with anAF_UNIXlistener and connection. Windows'AF_UNIXmisses a peer'sclosesocketwhich races arecventering its wait: therecvnever returns, though a secondrecvon the same socket gets EOF at once. It happens in plain C too, with blocking, overlapped and IOCP receives alike (a few to a few dozen times in 2000 rounds onwindows-latest), and never over TCP. The non-threaded RTS hits it in a Haskell program; it was found through simple-sendfile's test suite.This PR builds the pair over TCP on
127.0.0.1instead:TCP_NODELAY, as a stream pair should not delay small writes.AF_UNIXpair left behind goes, and so does thetemporarydependency on Windows.The pair's family is now
AF_INETon Windows; the arguments were already ignored there.The
socketPairtests now run on Windows too, with a new one where the peer closes while the other end waits inrecv. macOS, and Windows with GHC 9.8.2 and 9.12 (MIO and WinIO), pass.🤖 Generated with Claude Code