On Jan 29, 2008 10:58 AM, John Papas <[EMAIL PROTECTED]> wrote:
> I'm using file() to get the contents of a remote page in my script but
> I cannot find any information regarding how I could *gracefully*
> handle a broken network connection or even a time-out (slow
> connection).
>
> Is there a way?
>
> ---
> Example:
> $menu = file('http://www.remotesite.org/mypage.html');
> foreach ($menu as $line_num => $line) {
>     echo $line."\n";
> }
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I'm not exactly sure what you are trying to accomplish or what sort of
access you have to the server, but if it were me I wouldn't rely on a
remote connection in real time.  I would have a cron job that
periodically updated the results that I am expecting so that reads on
your site are very fast.  Like I said though I'm not sure what you're
using this for so I cannot say whether or not it is okay for you to
cache this data locally for 5 minutes or even 1 day.

If you can cache it but cannot run cron jobs, then just write the
return buffer to a file and hold that for as long as possible checking
the last time it was wrote to see if it needs a refresh.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to