Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTTP Server

A minimal HTTP/1.1 server written in C++17 using POSIX sockets. It is intended for learning and experimentation, not production traffic.

Requirements

  • Linux or another POSIX-compatible operating system
  • CMake 3.20 or newer
  • A C++17-compatible compiler

Build

From the repository root:

cmake -S . -B build
cmake --build build

The executable is written to build/http_server.

Run

./build/http_server

The server listens on TCP port 8080 on all local interfaces. In another terminal, send a request with:

curl http://127.0.0.1:8080/

The response body is:

OK

Stop the server with Ctrl+C.

Current Behavior

  • Accepts TCP connections sequentially.
  • Reads up to 2,047 bytes from each client request.
  • Applies a five-second receive and send timeout.
  • Returns HTTP/1.1 200 OK for any request that can be read.
  • Uses a listen backlog of 5 and enables SO_REUSEADDR.

This implementation does not parse HTTP methods, paths, headers, or request bodies. It does not provide routing, TLS, persistent connections, graceful shutdown, configuration, or production-level error handling.

Project Layout

.
├── include/socket.hpp       # RAII wrapper for a file descriptor
├── src/http-server.cpp      # Server and request handling
├── CMakeLists.txt           # Build configuration
└── LICENSE                  # MIT License

License

This project is licensed under the MIT License.

About

Minimal HTTP/1.1 server written in C++17 using POSIX sockets for learning and experimentation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages