Instead of just spinning up a Python or Express server, I wanted to build one from the ground up in C on Linux (WSL) to see what's actually happening at the OS level.
No external libraries or frameworks—just raw C and POSIX socket system calls.
When you hit localhost:8080 in your browser, here's the exact lifecycle:
socket()– Asks the kernel to allocate an IPv4 TCP socket (gives back File Descriptor3).bind()– Ties that socket handle to0.0.0.0:8080usingstruct sockaddr_in(andhtons()so network byte order doesn't flip the port).listen()– Tells the OS to start listening for incoming connections with a backlog queue of 10.accept()– Pauses execution until a connection arrives, then spawns a dedicated client handle (4) for that line.read()&write()– Captures the raw HTTP request header sent by the browser, then streams back anHTTP/1.1 200 OKheader with an HTML response.
You'll need gcc installed in a Linux environment or WSL.
- Clone the repo:
git clone [https://github.com/Ctrl-Yam/c-web-server.git](https://github.com/Ctrl-Yam/c-web-server.git) cd c-web-server