A lightweight, low-level HTTP server written in C++ using raw socket programming.
Designed for learning, experimentation, and showcasing low-resource server design without any frameworks.
- Accepts and processes HTTP GET requests
- Serves data based on path
- IP-based connection rate limiting to mitigate abuse (per-IP burst control)
- Fully manual request parsing using basic
read()/send() - Manual (low-level) struct management using pointers
Each client is tracked by IP, and a maximum of 10 connections is allowed in a short configurable window (MINSECPERTENCONS).
New connections that violate this window are deferred (connection is silently closed), and if necessary, banned, making the server more resistant to spam/floods.
Start the server:
./api-serverSend a request:
curl http://localhost:8080/
curl http://localhost:8080/api/utcsrc/
βββ server.cpp # Main server logic
βββ htdocs/index.html # Static HTML content
- C++20-compliant compiler (
g++,clang++, or MSVC) - POSIX-compatible system (Linux, macOS, WSL recommended)
- No external libraries required
Run the following in the root directory:
g++ -std=c++20 -o api-server src/server.cppThen start the server:
./api-serverThis project was built to understand:
- How HTTP actually works under the hood
- How to implement real-world protections (like rate limiting) manually
- How to structure a minimal API server in pure C++