From e130cf3a3b37a080823d79d7154d00e4fea7dd74 Mon Sep 17 00:00:00 2001 From: ThePiso <68948902+ThePiso@users.noreply.github.com> Date: Thu, 30 Jul 2020 16:11:02 +0200 Subject: [PATCH] The piso patch 1 (#590) * Update httplib.h When you disconnect and reconnect from the network, your network stack rewrites and updates /etc/resolv.conf accordingly. This configuration file is needed by the DNS resolver in the C library. The C library reads the DNS configuration from /etc/resolv.conf the first time, and caches it. It doesn't check, with every lookup, if the contents of /etc/resolv.conf have changed. the solution is to add a call to res_init(), defined in resolv.h * Update httplib.h --- httplib.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/httplib.h b/httplib.h index 9312227..225e73d 100644 --- a/httplib.h +++ b/httplib.h @@ -156,6 +156,9 @@ using socket_t = SOCKET; #include #include #include +#ifdef __linux__ +#include +#endif #include #ifdef CPPHTTPLIB_USE_POLL #include @@ -1821,6 +1824,9 @@ socket_t create_socket(const char *host, int port, int socket_flags, auto service = std::to_string(port); if (getaddrinfo(host, service.c_str(), &hints, &result)) { +#ifdef __linux__ + res_init(); +#endif return INVALID_SOCKET; }