Choosing Between GetAddrinfoEx and DNSQueryEx for Efficiently Resolving Multiple IP Addresses from Hostnames

Harshal Goyal 20 Reputation points
2025-01-02T06:30:35.6866667+00:00

Hi everyone,

I’m working on a project where I need to resolve hostnames or Fully Qualified Domain Names (FQDNs) to a list of IP addresses. The use case involves resolving a hostname to about a dozen or two IP addresses, and I’m evaluating which function would be most suitable for this purpose between GetAddrinfoEx and DNSQueryEx.

Here are my questions:

  1. What are the key differences between GetAddrinfoEx and DNSQueryEx in terms of performance, flexibility, intended use cases and ease of use for resolving multiple IPs from hostnames/FQDNs?
  2. Is there a specific situation where one function would be preferred over the other for resolving a hostname or FQDN to multiple IP addresses (i.e., in cases with high availability or multiple DNS records)?
  3. Which one would you recommend for resolving a hostname to multiple IP addresses efficiently in a scenario with as low as 1 -2 to dozen or more addresses?

Any insights into the advantages or best practices for using either of these functions in this context would be greatly appreciated!

Thanks in advance!

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,704 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.