cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Mailing List Archives

Re: Resolved IP out of libcurl? (Strike one)

From: Antti Tuominen <antti.tuominen_at_hiit.fi>
Date: Thu, 21 Apr 2005 14:52:15 +0300

> > 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...

I did just that, and to circumvent the ip4 vs ip6 problem, I return
data->state.connects[latest]->ip_addr_str as char*.

> 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...

I found that if I wait until multi says it's done with the transfer,
connections with HTTP keepalive find the IP just fine, others still have
data->state.numconnects == 1, but data->state.connects[0] == NULL...

I just take a local copy of the string already in curl_headerfunction.
Unsatisfactory, but it works...

> 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.

This is the proper way to go, I guess. Doesn't fit as nicely to the simple
types curl_easy_getinfo() usually returns, but probably it can't be avoided.

When a miracle occurs and I'm not deadline-bound, I could look at that.

-A

-- 
3 || 9
Received on 2005-04-21

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET