Accept a Connection
Every HTTP request begins with a client connecting to a server over a transport layer. For HTTP, the standard transport layer is the Transmission Control Protocol (TCP).
TCP provides a reliable, ordered, and error-checked delivery of a stream of bytes between applications. Without TCP, HTTP wouldn’t know if the data it sent actually arrived!
Your Task
Bind a TCP listener to port 8080 on 0.0.0.0, wait for an incoming connection, and successfully accept it.
Warning
Why
0.0.0.0and notlocalhost? If you bind your server to127.0.0.1(localhost), it will only accept connections from inside your host machine. Because our test suite runs inside a Docker container, it connects to your server via a virtual network bridge. Binding to0.0.0.0ensures your server listens on all network interfaces, allowing the Docker container to successfully reach it.
Important
Run the below docker command to test your solution.
docker run \ --rm \ --add-host host.docker.internal:host-gateway \ codeberg.org/level0/buildit/http-server:latest \ --addr host.docker.internal:8080 \ --until accept_connection
Reference: RFC 9110 Section 3.3