cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Resolved IP out of libcurl?

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Fri, 8 Apr 2005 15:37:16 +0200 (CEST)

On Fri, 8 Apr 2005, Antti Tuominen wrote:

> I looked at the source and it seems to me that adding an entry to
> curl_easy_getinfo() might do the trick.

Yes, that would be the logical place to add an option to get the IP of an
already resolved host.

Just keep in mind that a resolved IP is not necessarily IPv4...

> In Curl_getinfo(), data->state.connects looks promising, but then I couldn't
> figure out which one of the connects I should be looking at. Is there a
> (single) one with data->state.connects[i]->data == data, or are these
> necessarily even valid anymore after the transfer has been completed?

The connects[] array is the "connection cache". It is an array with struct
connectdata pointers, each identifying a live connection to a specific host.

You'll need to scan over the used ones to find the most recently used one and
have that return the address...

Another perhaps slightly more complicated way to do it, would be to access
libcurl's internal DNS cache to get the info. Then you could get a full
response back, with all known IP adresses etc.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2005-04-08