From fa2f03cbe5f22207386b66de6cc4c4d61215f79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Thu, 31 Aug 2023 12:40:57 +0200 Subject: [PATCH] * libwget/dns.c (resolve): Restrict socket type to SOCK_STREAM on Windows --- libwget/dns.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libwget/dns.c b/libwget/dns.c index 5c6158e4c..8c910ccff 100644 --- a/libwget/dns.c +++ b/libwget/dns.c @@ -227,7 +227,15 @@ static int resolve(int family, int flags, const char *host, uint16_t port, struc { struct addrinfo hints = { .ai_family = family, +#ifdef _WIN32 + // It looks like on Windows 0 is not a valid option here. + // see https://learn.microsoft.com/en-us/windows/win32/api/ws2def/ns-ws2def-addrinfoa + // TODO: On Windows, do two calls to getaddrinfo (for TCP and UDP) and merge the results. + // Alternatively, consider splitting caches by TCP and UDP addresses. + .ai_socktype = SOCK_STREAM, +#else .ai_socktype = 0, +#endif .ai_flags = AI_ADDRCONFIG | flags };