curl / Mailing Lists / curl-library / Single Mail


Retrieve all addresses mapped to specific host, not just one IP

From: myLC--- via curl-library <>
Date: Sat, 11 Aug 2018 11:56:14 +0200

Hello, :-)

I'm new to (lib)curl. I decided that this was the most
complete network implementation, after ditching Qt for
continuous multithreading issues.

I would like to know how we can retrieve all the IP
addresses which are mapped to a host.

Assuming we have the URL

and assuming further that there are 5 addresses mapped to
this hostname:,,,

How would I get them from libcurl?

The "inbound" network implementation (TR) of C++ (Boost
ASIO) returns an iterator upon having resolved a hostname.
If I'm correct, the implementation chooses the IP randomly
when connecting. Likewise, it tries the entire list of IPs
before giving up. I haven't checked out libcurl's source-
code, but I'm guessing that you will do something similar.
Virtually all the functions for resolving hostnames return
all the addresses (getaddrinfo, for instance).
Therefore, at some point, libcurl must have this
information. So, how do I get that list of all addresses?
I'm inquiring, because I would hate to employ a second
engine/dispatcher for this.

Thank you very much for your help!

Received on 2018-08-11