cURL / Mailing Lists / curl-users / Single Mail

curl-users

liburl dns cache?

From: Phillip Stevens <pj2k_at_hotmail.com>
Date: Mon, 01 Apr 2002 20:53:59 +1000

Hi,

I understand libcurl has a dns cache? will the following below cause two DNS
lookups? (PERL) I'm hoping it will only cause one lookup. How big can the
libcurl cache be? could it cache hundreds of domains before ending the
session? (before running cleanup) -

Thank you.

use Curl::easy;

# Init the curl session
my $curl= Curl::easy::init();
if(!$curl) {
    die "curl init failed!\n";
}

$::errbuf="";
Curl::easy::setopt($curl, CURLOPT_ERRORBUFFER, "::errbuf");

# FIRST REQUEST

my $url = "http://domain.com/page1.html";

Curl::easy::setopt($curl, CURLOPT_URL, $url);

sub body_callback {
    my ($chunk,$handle)=@_;
    push @$handle, $chunk;
    return length($chunk); # OK
}
Curl::easy::setopt($curl, CURLOPT_WRITEFUNCTION, \&body_callback);

my @body;

Curl::easy::setopt($curl, CURLOPT_FILE, \@body);

if (Curl::easy::perform($curl) != 0) {
    print "Failed :$::errbuf\n";
};

# SECOND REQUEST

my $url = "http://domain.com/page2.html";

Curl::easy::setopt($curl, CURLOPT_URL, $url);

sub body_callback {
    my ($chunk,$handle)=@_;
    push @$handle, $chunk;
    return length($chunk); # OK
}
Curl::easy::setopt($curl, CURLOPT_WRITEFUNCTION, \&body_callback);

my @body;

Curl::easy::setopt($curl, CURLOPT_FILE, \@body);

if (Curl::easy::perform($curl) != 0) {
    print "Failed :$::errbuf\n";
};

# Cleanup
Curl::easy::cleanup($curl);

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com
Received on 2002-04-01