This C++ project implements a simple multithreaded HTTP server using Boost Beast. The server listens for incoming HTTP connections, processes GET requests, and serves static files from a specified directory. The server efficiently handles multiple clients using a thread pool, ensuring better concurrency and performance.
You can watch a demo of the project in action here.
- 📡 File Serving: Processes HTTP GET requests and serves static files from a
resourcesdirectory. - 🧵 Multithreaded Handling: Uses a thread pool (6 threads by default) for efficient request processing.
- 🧩 Modular Codebase: Clean and separated code for easy maintenance.
- ⚡ High Performance: Handles 500-1000 RPS (Requests Per Second).
- 🔓 Safety Third: Who needs firewalls? This server exposes your whole computer to the internet💀
The project is designed using Object-Oriented Programming (OOP) principles. It is divided into three main parts:
main.cpp: Initializes the server, sets up signal handling for graceful shutdown, and starts listening for incoming connections.http_server.h: Declares theTcpServerclass, which manages socket operations, worker threads, and request handling.http_server.cpp: Implements theTcpServerclass, including socket creation, binding, listening, accepting client connections, parsing HTTP requests using Boost Beast, and responding to clients.
To compile and run the program, follow these steps:
-
Clone the repo:
git clone https://github.com/yourusername/cpp-http-server.git
-
Navigate to the project directory:
cd cpp-http-server -
Ensure Boost is installed on your system. If not, install it using your package manager. For example, on Ubuntu:
brew install boost -
Make the build files
cd build && cmake .. -
Compile the program:
make -
Run the server:
./server
-
Access the server: Open your web browser and navigate to
http://127.0.0.1:8080.
Handling a GET Request
Handling 1000 requests



