Reply to Re: Setting a timeout when using fopen.

Your name:

Reply:


Posted by Erwin Moller on 01/29/07 12:09

Erwin Moller wrote:

> Aetherweb wrote:
>
>> On my site I'm reading content from a URL with a statement like this:
>>
>> if ($fp = @fopen("http://www.mydom.com/test.aspx", "r"))
>> {
>> do something
>> }
>> else
>> {
>> do something else
>> }
>>
>> Which works absolutely fine if the remote site works, and fine if it's
>> totally unavailable... but sometimes the remote site allows the
>> connection, but takes EONS to server up any data. Which is totally
>> locking up my site.
>>
>> How could I go about having some kind of timeout on the file open
>> operation?
>
> Hi,
>
> fopen() can indeed handle URLs and return their content as it were a file
> (using the fopenwrappers).
>
> But if you need more control, you should use a socket.
> Have a look at fsockopen:
> http://nl2.php.net/manual/en/function.fsockopen.php
>
> look at the last parameter (timeout).

AHUM, scratch that last remark. ;-)

That timeout is only for the connectionprocess.
You need an extra function: stream_set_timeout() as described in the text.

Good luck.

Reagrds,
Erwin Moller

>
> Regards,
> Erwin Moller
>
>
>>
>> TIA

[Back to original 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

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