Jump to content


Photo

Setting a time limit on a CURL lookup?


  • Please log in to reply
1 reply to this topic

#1 Anidazen

Anidazen
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 09 August 2006 - 07:05 PM

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?

#2 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 09 August 2006 - 09:40 PM

Well, according to http://www.phpit.net...ing-curl-php/2/:

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.


RTFM is an almost extinct art form, it should be subsidized.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users