11# Introduction
22
3- This repository contains several versions of a HTTP Server implemented in CPP. The purpose
4- is to compare performance of different implementations and shows how one can optimize the
5- server to achieve beter through-put .
3+ A sample HTTP Server implemented using ` libevent ` .
4+
5+ This repository also contains several versions of a HTTP Server implemented in cpp .
66
77# Releases
88
9- To run the server, default host is 14396:
9+ To run the server, use the following command, default host is 14396:
1010
1111```
1212bazel run -c opt src/main/cpp:server
@@ -15,14 +15,14 @@ bazel run -c opt src/main/cpp:server
1515### Version 3.1.0
1616
1717The base class for server is ` ServerSocket ` at ` src/main/cpp/server_socket.h ` . I use an
18- ` evconnlistener ` from ` libevent ` to bind and listen on the server address. For a new connection
19- accepted , ` accept_conn_cb ` is called. The server passes the connection to one of the workers
20- (defined in ` src/main/cpp/server ` );
21-
22- The server worker runs an event loop, connections received from the server will be added for
23- monitoring. When the connection becomes active, ` conn_read_callback ` will be triggered. It reads
24- from the socket, parses the HTTP request, call ` HandleHttpRequest ` to produce an ` HttpResponse ` and
25- write the response to the connection socket.
18+ ` evconnlistener ` from ` libevent ` to bind and listen on the server address. For each new connection
19+ , ` accept_conn_cb ` is called. The server passes the connection to one of the workers to handle
20+ (defined in ` src/main/cpp/server ` ).
21+
22+ The server worker runs an event loop, connections received from the server will be added to the
23+ loop for monitoring. When the connection becomes active, ` conn_read_callback ` will be triggered. It
24+ reads from the socket, parses the HTTP request, call ` HandleHttpRequest ` to produce an
25+ ` HttpResponse ` and write the response to the connection socket.
2626
2727Some notes:
2828- Connections received from ` evconnlistener ` are non-blocking by default. When reading from
0 commit comments