TCP (Transmission Control Protocol) sits below HTTP and TLS in the networking stack, carrying application data over an established connection while lower protocols handle transmission details. section 8.1
TCP becomes concrete through two progressively lower-level approaches:
- Use Rust’s std::net::TcpStream to connect to a host, write an HTTP GET request, add the Host header, and copy the response to standard output. section 8.4
- Use smoltcp TCP primitives inside a manually assembled HTTP client, coordinating Ethernet, DNS resolution, URL parsing, and socket state. section 8.10
- Account for the boundary between names and network connections: TcpStream connects using an IP address, while the HTTP Host header supplies the hostname context. section 8.4
A minimal HTTP request over TCP
A Rust program connects to www.rustinaction.com:80, writes "GET / HTTP/1.0", terminates the request lines with CRLF, adds "Host: www.rustinaction.com", and streams the response to stdout. HTTP/1.0 is chosen so the server closes the connection after responding. section 8.4
Raw TCP work exposes operating-system boundaries: raw network requests typically require superuser access, while a Linux proxy device can provide direct access to non-superusers. A minimal client can model connection, request, and response states. section 8.8
Figure 8.2 Several layers of networking protocols involved with delivering content over the internet. The figure compares some common models, including the seven-layer OSI model and the four-layer TCP/IP model.
Compare the OSI and TCP/IP networking models to see TCP’s position among HTTP, TLS, Ethernet, and lower transmission layers. section 8.1




