Jump to content

Archived

This topic is now archived and is closed to further replies.

Anidazen

Setting a time limit on a CURL lookup?

Recommended Posts

Is it possible to set a timelimit within PHP, such as if CURL doesn't fetch a page in 5 seconds, give up trying.

Only way I can see at the moment is to have an entire-script timeout and lookup some satellite scripts... hardly an efficient process.


Any ideas?

Share this post


Link to post
Share on other sites
Well, according to [url=http://www.phpit.net/article/using-curl-php/2/]http://www.phpit.net/article/using-curl-php/2/[/url]:

[quote]The CURLOPT_CONNECTTIMEOUT is used to set how long curl should wait whilst trying to connect. This is a very important option, since it could cause requests to fail if you set it too low, but if you set it too high (e.g. 1000 or 0 for unlimited) it could cause your PHP scripts to crash. A related option to this is the CURLOPT_TIMEOUT option, which is used to set how long curl requests are allowed to execute. If you set this to a low value, it might cause slow pages to be incomplete, since they take a while to download.

[/quote]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.