9
pipe(my $libcurl, my $daemon)|| die $!;
11
unless (my $libcurlpid = fork) {
12
# Child -- libcurl thread
16
my $curlm = WWW::Curl::Multi->new;
17
my $curl_id = $$; # This should be a handle unique id.
18
my $active_handles = 0;
22
print "Got request $_\n";
23
my $curl = new WWW::Curl::Easy;
24
$easy{$curl_id} = $curl; # Register handle
25
$curl->setopt(CURLOPT_PRIVATE,$curl_id); # Assign Multi ID
26
# do the usual configuration on the handle
28
$curl->setopt(CURLOPT_VERBOSE, 1);
29
$curl->setopt(CURLOPT_DNS_CACHE_TIMEOUT, -1);
30
$curl->setopt(CURLOPT_NOBODY, 1);
32
$curl->setopt(CURLOPT_URL, $_);
34
# Add easy handles to multi
35
$curlm->add_handle($curl);
38
while (my $active_transfers = $curlm->perform) {
39
if ($active_transfers != $active_handles) {
40
while (my ($id,$return_value) = $curlm->info_read) {
43
my $actual_easy_handle = $easy{$id};
44
# do the usual result/error checking routine here
46
# letting the curl handle get garbage collected, or we leak memory.
68
print "$$: Sending request\n";
69
print $daemon "http://ftp.us.debian.org\n";