Re: fopen timeout
| From: | Alan Knowles | Date: | Sat, 20 Jul 2002 06:19:02 +0000 |
| Subject: | Re: fopen timeout | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-2274@lists.php.net to get a copy of this message | ||
since I assume you are using http etc. - the best bet is to use the socket library rather than fopen, this way you should be able to set non blocking etc.
- You may like to look at Net_Socket http://docs.akbkhome.com/pearcvs/Net_Socket.html which is available from pear.php.net - this uses the original php socket library
which will probably have the same problems as you had below, but provides a nice API to write a new socket package, using the new socket extension..
regards
alan
Erich Kolb wrote:
I am opening a series of documents over the internet using fopen inside of a
loop. Is there an easy way to set a timeout so that if the file is not
available, it will move to the next one?
while ($row = mysql_fetch_array($sql)) {
$channel_title = $row["ChannelTitle"];
$channel_link = $row["ChannelLink"];
$channel_dataurl = $row["ChannelDataURL"];
$fpread = fopen($channel_dataurl, 'r');
if(!$fpread){
echo "Error opening datafile: <b>$channel_dataurl</b>\n";
echo "$errstr ($errno)<br>\n";
}
}
...