curl-library
Re: Retrieve all addresses mapped to specific host, not just one IP
Date: Mon, 13 Aug 2018 16:36:19 -0400
https://curl.haxx.se//mail/lib-2018-08/0137.html
myLC--- via curl-library wrote:
> 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
> https://example.buzz/bingo_results/
>
> and assuming further that there are 5 addresses mapped to
> this hostname:
> 10.0.0.11, 10.0.0.12, 10.0.0.13,
> fd0e:34f4:760f:5bd6:0123:4567:89ab:cdef,
> fd0e:34f4:760f:5bd6:aaaa:bbbb:cccc:dddd
>
> 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.
I'm confused about what it is you are trying to do with the list of addresses?
- connect to each one and perform an operation?
- try to connect (simultaneously?) to several and find
the first one that works?
Are you asking libcurl to do a normal operation on a given host URL with host
name and oh, BTW, return whatever address list libcurl resolved?? This seems
like a highly specialized feature to add to libcurl.
It's not clear to me why you are trying to get libcurl to return that address
list. If you are on a modern system, you already have a way to do this:
getaddrinfo() or equivalent.
I guess I'm wondering if it makes more sense for your application to get the
list of addresses itself and then tell libcurl what to do with them. Is it
good enough to create URLs with each IP literal? Perhaps what you are looking
for is a way to perform the same operation on a given URL but with different
IP addresses? (All hosts see the same textual host name?) Possibly
simultaneously via multi?
Or have I totally missed something? To have discussions go right into API
details suggests that this is of more value than I thought, even though I
don't really understand why.
Cheers!
Rich
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2018-08-13