Home / HTTP Webserver

HTTP Webserver

November 2025 Networking / C++ C++20 · HTTP/1.1 · epoll

Overview

Webserv is an HTTP/1.1 web server written in modern C++20 that handles multiple concurrent connections using an epoll-based non-blocking event loop. It serves static files, executes CGI scripts, and supports virtual host routing — all configured via an NGINX-style .conf file.

A 42/Hive Helsinki team project built from scratch: no Boost, no Asio, just raw POSIX sockets, epoll, and fork/exec. It passes concurrent load tests and handles keep-alive connections with a 60-second idle timeout.

Key Features

Tech Stack

C++20 epoll POSIX Sockets CGI HTTP/1.1 Makefile

My Role

This was a three-person project. I was responsible for the networking core — the WebServer and Server classes that manage the epoll event loop, socket lifecycle (bind, listen, accept), and connection state across clients. I also drove integration and load testing across the different modules to verify correctness under concurrent connections.

Challenges & Learnings

The hardest part of my side was managing the full socket lifecycle correctly under concurrent load — handling partial reads and writes on non-blocking sockets, detecting stale connections, and ensuring the epoll event loop never missed or double-processed events. Getting EPOLLIN, EPOLLOUT, and EPOLLHUP transitions right for each connection state took significant iteration.

Beyond my own area, collaborating closely on the full project gave me a solid understanding of the HTTP/1.1 protocol — how requests and responses are structured, the role of headers like Content-Length and Transfer-Encoding, keep-alive semantics, and how CGI bridges the gap between the web and arbitrary processes. It was the project that made HTTP click as more than just a black box.