You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A short TCP send fails a TLS record: std.tcp has no write that sends a whole buffer #3108
tcp.write, tcp.write_n and tcp.write_slice each make one send(2) and return its count, and that count can be short. Every socket std.net opens has a 30 s send timeout (std/net/aether_net.c, net_set_socket_timeouts). When a peer reads slowly enough that one send runs into that timeout, the send returns the bytes that fit by then, and a signal can cut a send short the same way. std.tcp has nothing that sends a whole buffer, so each caller has to loop on the rest.
std/cryptography/tls13_client and tls13_server don't. They send each record with one tcp.write_n, and a short count is reported as "failed to send record". By then the peer already holds part of the record, so the handshake or the connection is lost.
Fix:
Add tcp.write_all(sock, data: byte[]). It sends until every byte is out or a send fails, and returns (sent, err).
The TLS modules send their records through it.
A test forces short sends (a small send buffer, a short send timeout, a peer that reads slowly). On a platform where one send comes back short, it shows that, and on every platform it checks that write_all delivers every byte in order.
contrib/tinyweb has the same problem in its WebSocket, SSE and chunked writes, along with frame bugs of its own; those are #3109.
Found on #3101 (#3107's migration of the TLS modules onto std.tcp).
changed the title [-]A short TCP send fails a TLS record, and tinyweb drops the rest of a response[/-][+]A short TCP send fails a TLS record: std.tcp has no write that sends a whole buffer[/+]on Oct 22, 2026
Fixed by e3c7eeb, "tcp.write_all, the TLS records and std.http's server send a whole buffer (#3108)", which merged with #3101 (the commit named the issue without a closing keyword, so it stayed open). Checked on main at 00df4c7 (0.848.0), MinGW gcc, Windows: make test (tests/runtime/test_runtime_net.c and test_http_server.c, 598 tests) passes.
Activity
[-]A short TCP send fails a TLS record, and tinyweb drops the rest of a response[/-][+]A short TCP send fails a TLS record: std.tcp has no write that sends a whole buffer[/+]tcp.write_all, the TLS records and std.http's server send a whole buf…
nicolas-maman commentedon Oct 26, 2026
Fixed by e3c7eeb, "tcp.write_all, the TLS records and std.http's server send a whole buffer (#3108)", which merged with #3101 (the commit named the issue without a closing keyword, so it stayed open). Checked on main at 00df4c7 (0.848.0), MinGW gcc, Windows: make test (tests/runtime/test_runtime_net.c and test_http_server.c, 598 tests) passes.
fix: std.tcp's write_all keeps what its send timeout means (#3257)