mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-10 09:43:51 +00:00
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:
parent
8a348f17fd
commit
e130cf3a3b
@ -156,6 +156,9 @@ using socket_t = SOCKET;
|
|||||||
#include <ifaddrs.h>
|
#include <ifaddrs.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <resolv.h>
|
||||||
|
#endif
|
||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
#ifdef CPPHTTPLIB_USE_POLL
|
#ifdef CPPHTTPLIB_USE_POLL
|
||||||
#include <poll.h>
|
#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);
|
auto service = std::to_string(port);
|
||||||
|
|
||||||
if (getaddrinfo(host, service.c_str(), &hints, &result)) {
|
if (getaddrinfo(host, service.c_str(), &hints, &result)) {
|
||||||
|
#ifdef __linux__
|
||||||
|
res_init();
|
||||||
|
#endif
|
||||||
return INVALID_SOCKET;
|
return INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user