Skip to content

Commit

Permalink
* libwget/dns.c (resolve): Restrict socket type to SOCK_STREAM on Win…
Browse files Browse the repository at this point in the history
…dows
  • Loading branch information
rockdaboot committed Aug 31, 2023
1 parent 3fb56d6 commit fa2f03c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libwget/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down

0 comments on commit fa2f03c

Please sign in to comment.