note 98415 added to function.curl-multi-exec

From: Date: Mon, 14 Jun 2010 17:46:51 +0000
Subject: note 98415 added to function.curl-multi-exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-170120@lists.php.net to get a copy of this message
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); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 158.158.241.250 ---- Manual Page -- http://www.php.net/manual/en/function.curl-multi-exec.php Edit -- https://master.php.net/note/edit/98415 Del: integrated -- https://master.php.net/note/delete/98415/integrated Del: useless -- https://master.php.net/note/delete/98415/useless Del: bad code -- https://master.php.net/note/delete/98415/bad+code Del: spam -- https://master.php.net/note/delete/98415/spam Del: non-english -- https://master.php.net/note/delete/98415/non-english Del: in docs -- https://master.php.net/note/delete/98415/in+docs Del: other reasons-- https://master.php.net/note/delete/98415 Reject -- https://master.php.net/note/reject/98415 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#170120) next »