From d8e89174e564920e77d53b16cc93db10bc246824 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 2 Sep 2024 13:38:19 +0200 Subject: [PATCH] net/Resolver: use gai_strerrorA() on Windows --- src/net/Resolver.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/net/Resolver.cxx b/src/net/Resolver.cxx index ec94baa1..915975f1 100644 --- a/src/net/Resolver.cxx +++ b/src/net/Resolver.cxx @@ -25,11 +25,17 @@ Resolve(const char *node, const char *service, { struct addrinfo *ai; int error = getaddrinfo(node, service, hints, &ai); - if (error != 0) + if (error != 0) { +#ifdef _WIN32 + const char *msg = gai_strerrorA(error); +#else + const char *msg = gai_strerror(error); +#endif throw FmtRuntimeError("Failed to resolve {:?}:{:?}: {}", node == nullptr ? "" : node, service == nullptr ? "" : service, - gai_strerror(error)); + msg); + } return AddressInfoList(ai); }