Home » Php » php – Why my curl connect_time is always equal to 0?

php – Why my curl connect_time is always equal to 0?

Posted by: admin July 12, 2020 Leave a comment


I’m trying to test some SOCKS proxy, and when trying to get the “ping” time of this proxy, I’m looking for the variable “connect_time”. For HTTP and HTTPS proxy, this seems to working fine, but not for SOCKS (SOCKS4 or SOCKS5) proxy where the connect_time is always equal to 0 (or almost…) !


Here is a piece of my code :

$options = array(
        CURLOPT_PROXY          => $proxy->ip.':'.$proxy->port,
        CURLOPT_TIMEOUT        => 30,
        CURLOPT_HEADER         => false,
        CURLOPT_HTTPHEADER     => array('Expect:'),
        CURLOPT_SSL_VERIFYHOST     => false,
        CURLOPT_SSL_VERIFYPEER     => false,
        CURLOPT_VERBOSE         => FALSE,
        CURLOPT_USERAGENT         => 'XXX',

if ($proxy->type == 'https')
    curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
elseif ($proxy->type == 'socks4')
elseif ($proxy->type == 'socks5')

When trying to ping (with ping…) this proxy from my computer, I’ve a ping time of about 50ms…

Is there a bug with curl or php ? Do you know can I retrieve the correct ping time ?

How to&Answers:

When using a proxy, the connect time is the time between the first response of the proxy and the end authentication. So basically your authentication process takes about 0.00023 seconds. Which is quite plausible.

I’m not sure if this is the intended way of how cURL should work because it looks like this is only the case when using proxies on cURL.

I’d consider it a bug.