Repository navigation
Add TCP networking and DNS to the standard library - #337
Open
pouya-eghbali wants to merge 4 commits into
Open
pouya-eghbali wants to merge 4 commits into
pouya-eghbali wants to merge 4 commits into
Conversation
pouya-eghbali
marked this pull request as ready for review
November 24, 2026 02:10
This branch has not been deployed
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.
What you can do
Use
std/netto connect by hostname, IPv4 or IPv6, bind a listener on an ephemeral port, accept connections, and stream bytes through the existingstd/streamandByteBufferAPIs. TCP preserves byte order and supports half-close. A program can finish sending and keep reading its peer’s response.splitconsumes the original connection. Its owner offerstakeReaderandtakeWriterso each half can move to a different task and close independently. Connection deadlines cover DNS and all address attempts. Listeners and byte streams accept per-operation timeouts. Pending network I/O yields the scheduler worker and observes task cancellation.Runtime and qualification
Streaming measurement
A single-worker, optimized macOS ARM64 process streamed a file to a loopback peer while writing the peer's independent response to a second file. The peer verified the upload and the harness verified every saved response byte. Three runs per size, alternating sizes, gave these process-level observations. Throughput counts both directions and includes file operations and process startup.
The documentation coverage test now checks individual signatures for all ten functions introduced by std/net. The full website check passes locally.
A separate one-worker TCP echo test sent 16 MiB and verified all 16 MiB coming back. With a reused 4 KiB Kalandra buffer, median combined throughput was 654 MiB/s across three runs (644–734 MiB/s), and process peak RSS was 6.05 MiB. Timing starts after connecting and ends at EOF. These are local loopback observations.
Hosted TCP results
Commit a71a525 passed the TCP source and ownership checks on macOS ARM64, Linux x86-64 and ARM64, and Windows x86-64 and ARM64. The tests exercise a deliberate short deadline separately from positive transfers and externally generated resets. The macOS development run also verified nine delayed resets with independent delays of 1, 100 and 250 ms.