Context
The TCP API currently has no way to bound connection, read, or write duration:
TcpStream::connect is used directly in src/tcp.rs:171-184
- reads and writes have no socket deadlines
tcp_read_until_impl grows a Vec until the delimiter or EOF at src/tcp.rs:92-115
A peer that never finishes connecting, never sends the requested bytes/delimiter, or continuously sends data without the delimiter can hang the program or grow memory without bound.
Suggested direction
Add deadline/timeout-aware variants for:
Add a bounded delimiter operation such as read_until!(stream, delimiter, max_bytes), or make the existing operation accept a limit if the API can still change before stable.
Keep error mapping portable and distinguish timeout from EOF and size-limit exhaustion. Be careful that DNS resolution can also block and may need separate treatment from per-address connect_timeout.
Acceptance criteria
- A caller can bound TCP connection, read, and write time.
- Delimiter reads have a finite caller-selected or documented maximum size.
- Timeout, unexpected EOF, and size-limit errors are distinct.
- Tests use a local helper server to cover stalled connect/read behavior and an over-limit delimiter-free stream.
- Existing unbounded behavior is either retained under explicitly named APIs or documented as a compatibility choice.
Context
The TCP API currently has no way to bound connection, read, or write duration:
TcpStream::connectis used directly insrc/tcp.rs:171-184tcp_read_until_implgrows aVecuntil the delimiter or EOF atsrc/tcp.rs:92-115A peer that never finishes connecting, never sends the requested bytes/delimiter, or continuously sends data without the delimiter can hang the program or grow memory without bound.
Suggested direction
Add deadline/timeout-aware variants for:
Add a bounded delimiter operation such as
read_until!(stream, delimiter, max_bytes), or make the existing operation accept a limit if the API can still change before stable.Keep error mapping portable and distinguish timeout from EOF and size-limit exhaustion. Be careful that DNS resolution can also block and may need separate treatment from per-address
connect_timeout.Acceptance criteria