cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-users Mailing List Archives

curl_multi does not processing multiple cURL handles in para

From: Administrator Proxy-List <v.simsive_at_gmail.com>
Date: Fri, 28 Mar 2008 11:59:31 +0400

Hello,

Description:
------------
curl_multi does not processing multiple cURL handles in parallel when SOCKS
type proxies are used. This could be easily determined by checking the spent
time or by using any NET software to check amount of opened connections for
particular process (you will see that curl_multi opens one or max two
connections at a time)

Reproduce code:
---------------
  $servers = file('servers.txt');
  
  function GetMicroTime() {
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
  }
  
  $mh = curl_multi_init();
  foreach ($servers as $server) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'http://google.com');
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_ENCODING, '');
    curl_setopt($ch, CURLOPT_PROXY, trim($server));
    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
    curl_multi_add_handle($mh, $ch);
  }

  $microTime = GetMicroTime();
  do {
    do {
    } while (curl_multi_exec($mh, $stillRunning) === CURLM_CALL_MULTI_PERFORM);
  } while ($stillRunning);
  $timeSpend = GetMicroTime() - $microTime;

  echo sprintf('%01.4f', $timeSpend);

Contents of 'servers.txt' file:
----------------
58.97.1.24:8081
221.195.1.82:81
218.25.105.18:3129
203.144.144.164:8081
210.51.9.250:3129
221.2.65.130:3129
123.136.24.13:8081
200.51.41.29:8081
81.189.106.138:8081
189.19.29.198:3129
  
Expected result:
----------------
Expected exit from the function under the specified timeout (~5 sec).

Actual result:
--------------
While the actual value vary from 20 till 35 sec.

p.s. If you simple HTTP type proxies will be used then the result will be as
expected ~5 sec.

p.p.s. I have submitted following bug at PHP web site but I think it is
more libcurl's bug rather then PHP's http://bugs.php.net/bug.php?id=44553
Received on 2008-03-28

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET