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
This commit is contained in:
ThePiso 2020-07-30 16:11:02 +02:00 committed by GitHub
parent 8a348f17fd
commit e130cf3a3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -156,6 +156,9 @@ using socket_t = SOCKET;
#include <ifaddrs.h>
#include <netdb.h>
#include <netinet/in.h>
#ifdef __linux__
#include <resolv.h>
#endif
#include <netinet/tcp.h>
#ifdef CPPHTTPLIB_USE_POLL
#include <poll.h>
@ -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;
}