|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-08-28 01:08 UTC] tobsn@php.net
Description: ------------ try the example code on the function.curl-multi-exec page in the manual with 20 different hosts (cnn, yahoo, blogspot, ask.com, etc.) it always returns 4 max. 6 sockets every after these connects giving a timeout. on the same host you ca force every number of sockets you want but on different you get a timeout after max. 6 sockets. (i tried it on 3 different machines each hosted on a different provider) Reproduce code: --------------- see the example code in the comments on the function.curl-multi-exec page in the manual. Expected result: ---------------- first 4-6 sockets get a page every socket after the first 4-6 bring back a timeout. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 15:00:02 2025 UTC |
<?php $u[] = 'www.yahoo.com'; $u[] = 'www.flickr.com'; $u[] = 'www.google.com'; $u[] = 'www.digg.com'; $u[] = 'www.shoutwire.com'; $u[] = 'www.example.com'; $u[] = 'www.cnn.com'; $u[] = 'www.ibm.com'; $u[] = 'www.winamp.com'; $u[] = 'www.linkup.com'; $u[] = 'www.nbc.com'; $u[] = 'www.amazon.com'; # uncomment this to test with a single host (should work with no timeouts in a snap) # $u = array_fill( 0, 20, 'www.google.com' ); $mh = curl_multi_init(); foreach( $u as $i => $d ) { $conn[$i] = curl_init( 'http://'.$d ); curl_setopt( $conn[$i], CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $conn[$i], CURLOPT_FOLLOWLOCATION, 1 );//follow redirects curl_setopt( $conn[$i], CURLOPT_MAXREDIRS, 1 );//maximum redirects curl_setopt( $conn[$i], CURLOPT_USERAGENT, 'Mediapartners-Google/2.1' ); curl_setopt( $conn[$i], CURLOPT_TIMEOUT, 20 ); curl_multi_add_handle( $mh, $conn[$i] ); } do { $mrc = curl_multi_exec( $mh, $active ); } while( $mrc == CURLM_CALL_MULTI_PERFORM ); while( $active and $mrc == CURLM_OK ) { if( curl_multi_select( $mh ) != -1 ) { do { $mrc = curl_multi_exec ($mh, $active ); } while( $mrc == CURLM_CALL_MULTI_PERFORM ); } } if( $mrc != CURLM_OK ) { print "Curl multi read error $mrc\n"; } foreach( $u as $i => $d ) { echo $i.' - '.$d."\n"; if( ( $err = curl_error( $conn[$i] ) ) == '' ) { echo 'found something'; } else { echo $err."\nnoconnect"; } echo "\n--\n"; curl_multi_remove_handle( $mh, $conn[$i] ); curl_close( $conn[$i] ); } curl_multi_close( $mh ); ?>