How lanqi1796-eng/cpp-reactor-http-server works
This is a learning-oriented C++17 HTTP/1.1 server. A client connection enters through the server’s listening socket; the EventLoop and Connection handle nonblocking I/O, the server parses and routes requests, then returns serialized responses. GET requests use static files; POST /echo is processed by a worker and handed back to the EventLoop for sending. The graph preserves the reactor, parsing, response, static-file, and worker-pool layers. Some links rely on README documentation because source excerpts omit wiring details.
Main entry points: TcpServer.cpp TCP server · Connection.cpp Connection I/O · EventLoop.cpp Event loop · StaticFileHandler.cpp Static files
Components 13
Server and routing
- TCP server
TcpServer.cpp - Echo processing
TcpServer.cpp
Reactor and sockets
- Event loop
EventLoop.cpp - FD channel
Channel.cpp - Connection I/O
Connection.cpp - Socket wrappers
wrap.cpp
HTTP handling
- Request parser
HttpRequest.cpp - Response serializer
HttpResponse.cpp - Static files
StaticFileHandler.cpp - Web assets
www/index.html
Async workers
- Thread pool
ThreadPool.h - Task queue
TaskQueue.h
Other components
- HTTP client
Connections 18
- HTTP client → TCP server: opens connection
README.md - TCP server → Socket wrappers: creates listener
TcpServer.cpp - TCP server → Event loop: registers listener
TcpServer.cpp - Event loop → FD channel: dispatches events
README.md - TCP server → Connection I/O: creates connection
TcpServer.cpp - Connection I/O → FD channel: configures events
- Connection I/O → Socket wrappers: uses socket I/O
- Connection I/O → Event loop: queues callbacks
README.md - TCP server → Request parser: parses requests
TcpServer.cpp - TCP server → Static files: routes GET
TcpServer.cpp - Static files → Web assets: reads files
README.md - Static files → Response serializer: sets response
- TCP server → Response serializer: serializes replies
TcpServer.cpp - TCP server → Thread pool: submits echo task
TcpServer.cpp - Thread pool → Task queue: queues tasks
ThreadPool.h - Thread pool → Echo processing: runs task
README.md - Echo processing → Event loop: queues result
TcpServer.cpp - Connection I/O → HTTP client: sends response
README.md