I'm looking at the sample code at php.net which explains how to open connections to multiple URLs simultaneously with cURL. But I don't understand what the 2 loops do and why is there 2 of them?
//execute the handles
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($mh) != -1) {
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
I found a resource online which shows this example, but there's no clear explanation as to what each of these loops does and how are they connected.
They mention that first loop has a non-blocking function and the second loop has blocking function. What does that mean?
Can someone please explain why are there 2 loops and what do they do?
Also what is CURLM_CALL_MULTI_PERFORM, php.net shows it inside the code, but there's no reference as to what it is.
Sorry spent the whole day researching the answer and this is my last resort. Hoping someone can help.