cURL / Mailing Lists / curl-and-php / Single Mail


curl_easy_init + curl_easy_setopt + timeout in milliseconds 'CURLOPT_TIMEOUT_MS'

From: Suleman Butt <>
Date: Fri, 28 Sep 2007 19:26:17 +0200

Hi Folks,
          I'm using PHP 5.2.4 with curl-7.17.0 patch. Now when I run this
following small code snippet,

// create both cURL resources
$ch1 = curl_init();
$ch2 = curl_init();

// set URL and other appropriate options
curl_easy_setopt($ch1, CURLOPT_URL, "");
curl_easy_setopt($ch1, CURLOPT_TIMEOUT_MS, 500);
curl_easy_setopt($ch1, CURLOPT_HEADER, 0);

curl_setopt($ch2, CURLOPT_URL, "");
curl_setopt($ch2, CURLOPT_TIMEOUT, 5);
curl_setopt($ch2, CURLOPT_HEADER, 0);

//create the multiple cURL handle
$mh = curl_multi_init();

//add the two handles

//execute the handles
do {
if($running == 0){
echo "Suleman";
echo "||";
echo $running;
} while ($running > 0);

//close the handles


I get this error: Fatal error: Call to undefined function *
curl_easy_setopt()* line 7.
I have also tried $ch1 = curl_easy_init();
but then i get the error: Fatal error: Call to undefined function
curl_easy_init() line 3.

Now could anybody please tell me how can i use 'curl_easy_setopt()' function
with "CURLOPT_TIMEOUT_MS" option?

The default curl_setopt() method with simple timeout param provides timeout
value only in *seconds*, where as i want to set the value for the *timeout
in milliseconds*. And i'm opening parallel connections to the urls (multi

To my knowledge, setting Execution Timout in milliseconds (
CURLOPT_TIMEOUT_MS) is only possible thrrough easy functions (curl_easy_init,
curl_easy_setopt), but i can't figure it out how to handle this fatal errro
:(..pls help anybody.


Regards Suleman

Received on 2007-09-28