You are here: Re: [newbie help] « All PHP « IT news, forums, messages
Re: [newbie help]

Posted by Janwillem Borleffs on 10/21/05 22:53

Ben Jamieson wrote:
> The URL I am accessing is often unavailable, as the server goes down a
> lot. Shouldn't this script simply give up after 4 seconds? It
> doesn't. It times out after ~2 minutes.
>

There are a couple of things going wrong here. First, you call
stream_set_timeout() after you have called fread(), while it should be the
other way around.

Second, the stream_set_timeout() function only works on the output stream of
the connection, *after* the connection to the remote source has been
established. When the stream doesn't timeout, but the connection does,
stream_get_meta_data() won't get anything.

What you need to catch this, is a way to set the timeout for the connection.
Since PHP5, you can do this with the fopen() function by using the 4th
argument to this function (see the manual for more info). Using a lower
version, you can apply the fsockopen() function, which accepts a timeout as
one of its arguments; see: http://www.php.net/fsockopen.


JW

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация