4 function main_test_curl_multi_except() {
5 $port = $_ENV['SERVERPORT'];
6 $host = php_uname('n');
7 $url = "http://$host:$port/hello.php";
12 curl_setopt($ch1, CURLOPT_URL
, $url);
13 curl_setopt($ch1, CURLOPT_HEADER
, 0);
14 curl_setopt($ch1, CURLOPT_WRITEFUNCTION
, 'except');
15 curl_setopt($ch2, CURLOPT_URL
, $url);
16 curl_setopt($ch2, CURLOPT_HEADER
, 0);
18 $mh = curl_multi_init();
20 curl_multi_add_handle($mh,$ch1);
21 curl_multi_add_handle($mh,$ch2);
25 $mrc = curl_multi_exec($mh, inout
$active);
26 } while ($mrc == CURLM_CALL_MULTI_PERFORM
);
29 while ($active && $mrc == CURLM_OK
) {
30 if (curl_multi_select($mh) != -1) {
33 $mrc = curl_multi_exec($mh, inout
$active);
34 } catch (Exception
$e) {
35 $ret .= ":::Exception: " . $e->getMessage() . "\n";
37 } while ($mrc == CURLM_CALL_MULTI_PERFORM
);
41 curl_multi_close($mh);
46 throw new Exception("oops");