[eluser]ronnie_nsu[/eluser]
hi Guys
I have this following code which actually tries to get content of three website with curl
Code:
$nodes = array(
'http://localhost:8080/ngbdcart/index.php/checkout_shipping/run_carrier/run',
'www.microsoft.com',
'www.newgenbd.net'
);
$node_count = count($nodes);
$curl_arr = array();
$master = curl_multi_init();
for ($i = 0; $i < $node_count; $i++) {
$url = $nodes[$i];
$curl_arr[$i] = curl_init($url);
curl_setopt($curl_arr[$i], CURLOPT_HEADER, 0);
curl_setopt($curl_arr[$i], CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_arr[$i], CURLOPT_TIMEOUT, 30);
curl_multi_add_handle($master, $curl_arr[$i]);
}
$running = NULL;
do {
curl_multi_exec($master, $running);
usleep (250000);
} while ($running > 0);
echo "results: <br/>";
for ($i = 0; $i < $node_count; $i++) {
$results = curl_multi_getcontent($curl_arr[$i]);
echo $results;
curl_multi_remove_handle($master,$curl_arr[$i]);
}
curl_multi_close($master);
echo 'done';
the problem is the i get output from last two urls in the $nodes array...but for the locahost.. one i get response randomly...
and the
run() function is a very simple it just echos one word "Helloooo"
anyone knows how to solve this problem???
Thanks in advance