C++ Multi-Threaded HTTP Server
A lightweight, high-performance HTTP web server implemented from scratch in modern C++ (C++17).
This project features a custom thread pool architecture to handle concurrent client connections efficiently.
Features
- Custom Thread Pool: Efficient worker thread management using condition variables and mutexes for parallel request processing.
- Socket Programming: Low-level network communication utilizing POSIX sockets (IPv4, TCP).
- Zero External Dependencies: Built purely with standard C++ libraries and POSIX system calls.
Project Structure
cpp-http-server/
├── include/
│ ├── server.hpp
│ └── threadpool.hpp
└── src/
├── main.cpp
├── server.cpp
└── threadpool.cpp
Getting Started
Prerequisites
- A C++17 compatible compiler (like
g++orclang) - A Linux or macOS environment (POSIX-compliant system)
Compilation Navigate to the project root directory and run the following command:
g++ -std=c++17 src/main.cpp src/server.cpp src/threadpool.cpp -o server -lpthreadRunning the Server Execute the compiled binary:
./serverThe server will start listening on port 8080. Open your browser and navigate to http://localhost:8080.