note 105252 added to function.curl-multi-init

From: Date: Fri, 05 Aug 2011 07:21:31 +0000
Subject: note 105252 added to function.curl-multi-init
Groups: php.notes 
Request: Send a blank email to php-notes+get-182242@lists.php.net to get a copy of this message
Simulate multiple threads request: <?php function multiple_threads_request($nodes){ $mh = curl_multi_init(); $curl_array = array(); foreach($nodes as $i => $url) { $curl_array[$i] = curl_init($url); curl_setopt($curl_array[$i], CURLOPT_RETURNTRANSFER, true); curl_multi_add_handle($mh, $curl_array[$i]); } $running = NULL; do { usleep(10000); curl_multi_exec($mh,$running); } while($running > 0); $res = array(); foreach($nodes as $i => $url) { $res[$url] = curl_multi_getcontent($curl_array[$i]); } foreach($nodes as $i => $url){ curl_multi_remove_handle($mh, $curl_array[$i]); } curl_multi_close($mh); return $res; } print_r(muti_thread_request(array( 'http://www.abc.com', 'http://www.xyz.com', ))); ---- Server IP: 69.147.83.197 Probable Submitter: 119.145.40.161 ---- Manual Page -- http://www.php.net/manual/en/function.curl-multi-init.php Edit -- https://master.php.net/note/edit/105252 Del: integrated -- https://master.php.net/note/delete/105252/integrated Del: useless -- https://master.php.net/note/delete/105252/useless Del: bad code -- https://master.php.net/note/delete/105252/bad+code Del: spam -- https://master.php.net/note/delete/105252/spam Del: non-english -- https://master.php.net/note/delete/105252/non-english Del: in docs -- https://master.php.net/note/delete/105252/in+docs Del: other reasons-- https://master.php.net/note/delete/105252 Reject -- https://master.php.net/note/reject/105252 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182242) next »