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: libcurl function to specify IP address of webserver (bypassin g DNS)

From: Becker, Dan <dbecker_at_3eti.com>
Date: Wed, 9 Jul 2003 09:59:58 -0400

Henrik,

I just use sprintf to handle the name mangling, relatively clean. It goes
something like this:

        // WARNING these strings must stay around between curl_easy_setopt &
curl_easy_perform
        char addr_string[500];
        ...

        cur_ip_addr = current_web_site->list_of_ip_addresses;
        while (cur_ip_addr) {
                sprintf(addr_string, "http://%s/", cur_ip_addr->ip_address);
                curl_easy_setopt(curl, CURLOPT_URL, addr_string);
                ...
                res = curl_easy_perform(curl);

                cur_ip_addr = cur_ip_addr->next_ip_addr;
        }

Dan

----------------------------------------------------------------------
Dan Becker email:dbecker_at_3eti.com
----------------------------------------------------------------------

-----Original Message-----
From: Henrik StÝrner [mailto:henrik-curl_at_hswn.dk]
Sent: Tuesday, July 08, 2003 5:11 PM
To: curl-library_at_lists.sourceforge.net
Subject: libcurl function to specify IP address of webserver (bypassing
DNS)

Greetings!

I am happily using libcurl to build an add-on for the Big Brother
network monitor (http://bb4.com/). Part of this involves testing
that webservers are alive and respond to requests; libcurl has
made that job a lot easier.

One thing I am missing is the ability to control exactly which
server libcurl connects to when curl_easy_perform() is invoked.
At work I want to test a load-balanced set of servers; if I just
provide the hostname as "http://www.somesite.com/", I have no
control over which of the three DNS entries for "www.somesite.com"
I end up testing.

So my question is: Would it be possible to implement a libcurl
function that tells curl which IP-address to connect to,
bypassing the normal DNS lookup ? Something like

   curl_easy_setopt(handle, CURLOPT_SERVER_IP, "192.168.1.2");
   curl_easy_setopt(handle, CURLOPT_URL, "http://www.foo.com/");
   curl_easy_perform(handle);

I guess it *could* be done by mangling the URL to replace the
hostname with the IP-address I want, then calling curl_easy_setopt
with CURLOPT_HTTPHEADER and defining the "Host:" header. But
I'd rather avoid mangling the URL myself.

-- 
Henrik Storner
-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps
-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps
Received on 2003-07-09

These mail archives are generated by hypermail.

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

File upload with ASP.NET