1+
12#include " tcp_socket.h"
23
34#include < chrono>
@@ -18,11 +19,11 @@ using namespace ipsockets;
1819using namespace std ::chrono_literals;
1920
2021#if true
21- static const ip_type_e cfg_ip_type = v4;
22- static const addr4_t cfg_server = " 127.0.0.1:8080" ;
22+ static const ip_type_e ip_type = v4;
23+ static const addr4_t ip_server = " 127.0.0.1:8080" ;
2324#else
24- static const ip_type_e cfg_ip_type = v6;
25- static const addr6_t cfg_server = " [::1]:8080" ;
25+ static const ip_type_e ip_type = v6;
26+ static const addr6_t ip_server = " [::1]:8080" ;
2627#endif
2728
2829// ============================================================
@@ -45,8 +46,8 @@ struct mini_http_server_t {
4546 std::map<std::string, std::function<std::string()> > routes;
4647
4748 std::chrono::steady_clock::time_point start_time;
48- uint64_t total_requests;
49- std::map<std::string, uint64_t > route_count;
49+ uint64_t total_requests;
50+ std::map<std::string, uint64_t > route_count;
5051
5152 // ===== constructor / destructor =====
5253
@@ -86,10 +87,10 @@ struct mini_http_server_t {
8687 address_t client_addr;
8788
8889 // Main accept loop
89- while (!must_die && server_socket.state == state_e::state_opened ) {
90+ while (!must_die && server_socket.state == state_e::opened ) {
9091
9192 tcp_client_t client = server_socket.accept (client_addr);
92- if (client.state != state_e::state_opened ) continue ;
93+ if (client.state != state_e::opened ) continue ;
9394
9495 // Handle client in separate thread
9596 tasks.push_back (std::async (std::launch::async,&mini_http_server_t ::handle_client,this ,std::move (client),client_addr));
@@ -348,11 +349,11 @@ struct mini_http_server_t {
348349
349350int main () {
350351
351- mini_http_server_t <cfg_ip_type > server (cfg_server );
352+ mini_http_server_t <ip_type > server (ip_server );
352353
353354 std::cout << " \n Mini HTTP Server is running!\n " ;
354355 std::cout << " Open your browser and visit:\n " ;
355- std::cout << " http://" << cfg_server << " /\n " ;
356+ std::cout << " http://" << ip_server << " /\n " ;
356357 std::cout << " \n Available routes:\n " ;
357358 std::cout << " / - Home page\n " ;
358359 std::cout << " /about - About page\n " ;
0 commit comments