note 98415 deleted from function.curl-multi-exec by danbrown

From: Date: Mon, 14 Jun 2010 17:51:53 +0000
Subject: note 98415 deleted from function.curl-multi-exec by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-170123@lists.php.net to get a copy of this message
Note Submitter: scott at eyefruit dot com ---- A lot of the code examples of how to check for the cURL status are inefficient, needlessly complex or else poorly documented. Here is an efficient, commented loop that will accomplish the same thing as the code in the official documentation under the comment "execute the handles": <?php $multiCurl = curl_multi_init(); # ... $curlStatus = null; $activeHandles = 0; # Loop until all handlers have finished loading or until an error occurs. do { # Start processing data with the inner loop if it's the first time through or if after # waiting for up to a second (inside curl_multi_select) we know there is data ready. if (is_null($curlStatus) || curl_multi_select($multiCurl) > 0) { # Keep processing until cURL tells us that it doesn't have any more data ready to # be processed right now (i.e., $curlStatus isn't set to CURLM_CALL_MULTI_PERFORM). do { $curlStatus = curl_multi_exec($multiCurl, $activeHandles); } while ($curlStatus == CURLM_CALL_MULTI_PERFORM); } } while ($activeHandles > 0 && $curlStatus == CURLM_OK); ?>

« previous php.notes (#170123) next »