note 80977 added to function.curl-multi-exec

From: Date: Sat, 09 Feb 2008 04:04:21 +0000
Subject: note 80977 added to function.curl-multi-exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-135926@lists.php.net to get a copy of this message
http://curl.haxx.se/libcurl/c/libcurl-multi.html "When you've added the handles you have for the moment (you can still add new ones at any time), you start the transfers by call curl_multi_perform(3). curl_multi_perform(3) is asynchronous. It will only execute as little as possible and then return back control to your program. It is designed to never block. If it returns CURLM_CALL_MULTI_PERFORM you better call it again soon, as that is a signal that it still has local data to send or remote data to receive." So it seems the loop in sample script should look this way: <?php $running=null; //execute the handles do { while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($mh, $running)); if (!$running) break; while (($res = curl_multi_select($mh)) === 0) {}; if ($res === false) { echo "<h1>select error</h1>"; break; } } while (true); ?> This worked fine (PHP 5.2.5 @ FBSD 6.2) without running non-blocked loop and wasting CPU time. However this seems to be the only use of curl_multi_select, coz there's no simple way to bind it with other PHP wrappers for select syscall. ---- Server IP: 69.147.83.197 Probable Submitter: 77.122.255.205 ---- Manual Page -- http://www.php.net/manual/en/function.curl-multi-exec.php Edit -- https://master.php.net/note/edit/80977 Del: integrated -- https://master.php.net/note/delete/80977/integrated Del: useless -- https://master.php.net/note/delete/80977/useless Del: bad code -- https://master.php.net/note/delete/80977/bad+code Del: spam -- https://master.php.net/note/delete/80977/spam Del: non-english -- https://master.php.net/note/delete/80977/non-english Del: in docs -- https://master.php.net/note/delete/80977/in+docs Del: other reasons-- https://master.php.net/note/delete/80977 Reject -- https://master.php.net/note/reject/80977 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135926) next »