A lightweight C++ web server built to explore low-level networking, HTTP request handling, multithreading, and concurrent client connections.
This project uses POSIX sockets directly instead of a web framework, making the request/response flow easy to inspect and extend.
- TCP socket setup with
socket,bind,listen, andaccept - Basic HTTP/1.1 responses with status line, headers, and body
- One detached worker thread per client connection
- Simple health-check route for smoke testing
- Small Makefile-based build with no external dependencies
- Linux or another POSIX-like environment with socket APIs
g++with C++17 supportmake
makeThis creates a server executable in the project root.
./serverBy default, the server listens on:
http://0.0.0.0:8080
From the same machine, use 127.0.0.1 in your browser or curl:
curl http://127.0.0.1:8080/| Method | Path | Response |
|---|---|---|
GET |
/ |
Small HTML page |
GET |
/health |
OK |
GET |
anything else | 404 Not Found |
.
|-- Makefile
|-- README.md
|-- http_tcpServer.cpp
|-- http_tcpServer.h
`-- server.cpp
server.cppcreates the server and starts the listen loop.http_tcpServer.hdeclares thehttp::TcpServerAPI.http_tcpServer.cppcontains the socket setup, client handling, and HTTP response generation.
make cleanThis is an educational server, not a production HTTP implementation. It intentionally keeps parsing, routing, and thread management simple so the networking mechanics stay visible.