Web студия "GrandView"
  Главная   Написать Контакты
   
   
О проекте
Руководство php
 

curl_multi_exec

(PHP 5)

curl_multi_exec -- Выполняет операции с набором cURL дескрипторов

Описание

int curl_multi_exec ( resource mh )

Внимание

К настоящему времени эта функция еще не была документирована; для ознакомления доступен только список аргументов.

См. также описание функций curl_multi_init() и curl_exec().



curl_multi_getcontent> <curl_multi_close
Last updated: Fri, 26 Jan 2007
 
add a note add a note User Contributed Notes
curl_multi_exec
robert dot reichel at boboton dot com
20-Oct-2007 05:54
I was testing PHP code provided by dtorop933@gmail.com in curl_multi_exec section of PHP Manual.

The part of the code '$err = curl_error($conn[$i])' should return error message for each cURL session, but it does not.
The function curl_error() works well with the curl_exec(). Is there any other solution for getting session error message with curl_multi_exec() or there is a bug in cURL library.

The script was tested with Windows XP and PHP-5.2.4
shichuanr at gmail dot com
06-Sep-2007 05:12
For people who have problem running the above example script(Example 425. curl_multi_exec()), you can alter it a little bit to make it work properly by replacing the existing chunk of code with the one below:

<?php
// create both cURL resources
$ch1 = curl_init();
$ch2 = curl_init();

// set URL and other appropriate options
curl_setopt($ch1, CURLOPT_URL, "http://www.google.com/");
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/");
curl_setopt($ch2, CURLOPT_HEADER, 0);

//create the multiple cURL handle
$mh = curl_multi_init();

//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);

$running=null;
//execute the handles
do {
   
curl_multi_exec($mh,$running);
} while (
$running > 0);
//close the handles
curl_multi_remove_handle($mh,$ch1);
curl_multi_remove_handle($mh,$ch1);
curl_multi_close($mh);

?>
substr(&#34;iscampifriese&#34;,1,11) dot &#34; at beer dot com&#34;
04-Jul-2007 06:10
If you are using mulit handles and you wish to re-execute any of them (if they timed out or something), then you need to remove the handles from the mulit-handle and then re-add them in order to get them to re-execute.  Otherwise cURL will just give you back the same results again without actually retrying.
dtorop933 at gmail dot com
07-Jan-2005 10:21
<?php
$connomains
= array(
  
"http://www.cnn.com/",
  
"http://www.canada.com/",
  
"http://www.yahoo.com/"
);

$mh = curl_multi_init();

foreach (
$connomains as $i => $url) {
 
$conn[$i] = curl_init($url);
 
curl_setopt($conn[$i], CURLOPT_RETURNTRANSFER, 1);
 
curl_multi_add_handle ($mh,$conn[$i]);
}

// start performing the request
do {
 
$mrc = curl_multi_exec($mh, $active);
} while (
$mrc == CURLM_CALL_MULTI_PERFORM);

while (
$active and $mrc == CURLM_OK) {
 
// wait for network
 
if (curl_multi_select($mh) != -1) {
   
// pull in any new data, or at least handle timeouts
   
do {
     
$mrc = curl_multi_exec($mh, $active);
    } while (
$mrc == CURLM_CALL_MULTI_PERFORM);
  }
}

if (
$mrc != CURLM_OK) {
  print
"Curl multi read error $mrc\n";
}

// retrieve data
foreach ($connomains as $i => $url) {
  if ((
$err = curl_error($conn[$i])) == '') {
   
$res[$i]=curl_multi_getcontent($conn[$i]);
  } else {
    print
"Curl error on handle $i: $err\n";
  }
 
curl_multi_remove_handle($mh,$conn[$i]);
 
curl_close($conn[$i]);
}
curl_multi_close($mh);

print_r($res);
?>

curl_multi_getcontent> <curl_multi_close
Last updated: Fri, 26 Jan 2007
 
 
Новости
11 июля 2007
Сайт запущен
© 2007 info@grandviewstudio.com

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 324

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 330
Z058440144362 Z348613067571