Skip to content

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multithreaded HTTP Server in C++

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.

Demo video


Features 🚀

  • 📡 File Serving: Processes HTTP GET requests and serves static files from a resources directory.
  • 🧵 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💀

Design

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 the TcpServer class, which manages socket operations, worker threads, and request handling.
  • http_server.cpp: Implements the TcpServer class, including socket creation, binding, listening, accepting client connections, parsing HTTP requests using Boost Beast, and responding to clients.

How to Run

To compile and run the program, follow these steps:

  1. Clone the repo:

    git clone https://github.com/yourusername/cpp-http-server.git
  2. Navigate to the project directory:

    cd cpp-http-server
  3. Ensure Boost is installed on your system. If not, install it using your package manager. For example, on Ubuntu:

    brew install boost
    
  4. Make the build files

    cd build && cmake ..
    
  5. Compile the program:

    make 
    
  6. Run the server:

    ./server
  7. Access the server: Open your web browser and navigate to http://127.0.0.1:8080.


Screenshots

Server Startup Server Startup

Handling a GET Request

Handling GET

Handling 1000 requests

Lightning Mcqueen


About

No description, website, or topics provided.

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages