cURL / Mailing Lists / curl-library / Single Mail

curl-library

liburl dns cache?

From: Phillip Stevens <pj2k_at_hotmail.com>
Date: Tue, 02 Apr 2002 18:34:07 +1000

I believe this is the better list I should be posting to.

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);

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
Received on 2002-04-02