Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable IPV6_V6ONLY flag to increase reliability of IPv4 service #2343

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ext/cpp-httplib/httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -3163,13 +3163,13 @@ socket_t create_socket(const std::string &host, const std::string &ip, int port,
if (socket_options) { socket_options(sock); }

if (rp->ai_family == AF_INET6) {
auto no = 0;
auto yes = 1;
#ifdef _WIN32
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
reinterpret_cast<const char *>(&no), sizeof(no));
reinterpret_cast<const char *>(&yes), sizeof(yes));
#else
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
reinterpret_cast<const void *>(&no), sizeof(no));
reinterpret_cast<const void *>(&yes), sizeof(yes));
#endif
}

Expand Down