we (web engine): Experimental web browser project to understand the limits of Claude

TCP socket wrapper (std::net) #57

open opened by pierrelf.com

Phase 6: TCP Socket Wrapper#

Implement a TCP socket abstraction in the net crate wrapping std::net::TcpStream.

Requirements#

  • TcpConnection type: wraps std::net::TcpStream
    • connect(addr: &str, port: u16) -> Result<TcpConnection>
    • read(buf: &mut [u8]) -> Result<usize>
    • write(data: &[u8]) -> Result<usize>
    • write_all(data: &[u8]) -> Result<()>
    • read_exact(buf: &mut [u8]) -> Result<()>
    • set_read_timeout(duration: Option<Duration>) -> Result<()>
    • set_write_timeout(duration: Option<Duration>) -> Result<()>
    • shutdown() -> Result<()>
  • Error type: NetError enum covering connection refused, timeout, DNS resolution failure, I/O errors
  • Buffered I/O: BufReader/BufWriter wrappers or equivalent for efficient line-oriented reading

Dependencies#

  • Only std::net and std::io (standard library)

Acceptance Criteria#

  • Connect to a TCP server by hostname:port
  • Read and write bytes
  • Timeout support
  • Proper error types and propagation
  • Unit tests (at minimum, test error types and construction)
  • cargo clippy and cargo fmt clean
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mguyk2slhb2f