I use multi curl to sending requests and want to know, when exactly each request sending. I have simple function from manual like this :
function multirequest($urls) //may be $urls contains 10 urls, or may be 1 000
{
$multi = curl_multi_init();
$handles = [];
$htmls = [];
for($i=0; $i<count($urls);$i++)
{
$ch = curl_init('https://....');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_multi_add_handle($multi, $ch);
array_push($handles, $ch);
}
do {
$mrc = curl_multi_exec($multi, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && $mrc == CURLM_OK)
{
if (curl_multi_select($multi) == -1)
{
usleep(1);
}
do
{
$mrc = curl_multi_exec($multi, $active);
}while($mrc == CURLM_CALL_MULTI_PERFORM);
}
foreach($handles as $channel)
{
$html = curl_multi_getcontent($channel);
$htmls[] = $html;
curl_multi_remove_handle($multi, $channel);
}
curl_multi_close($multi);
return $htmls;
}
I think, everyone used this code. I know, that it's possible to use callback
to find response time via microtime()
function. But I don't understand how to find the moment, when request start send ? Is that possible to set sequence of requests in multi curl ? Could someone help ? Thank you.
UPD
Is that possible to set sequence of requests in multi curl ? I am not sure,that first $ch
in array will be really send first.