Re: How to set a timeout limit for a call of a connection?
| From: | Alex Shi | Date: | Tue, 11 Mar 2003 01:23:29 +0000 |
| Subject: | Re: How to set a timeout limit for a call of a connection? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-139060@lists.php.net to get a copy of this message | ||
> > I have a script in which there is a call to open a remote file:
> >
> > fopen
> > ("http://www.somewhere.com/file.php?foo=bar",
> > "r");
> >
> > Sometimes if www.somewhere.com is down, it will stuck at the function
> > for very long a time. I hope to setup a timeout limit for this
> function
> > (just
> > this), so that it won't stay very long to wait for a result, but just
> quit
> > if the
> > call take a time longer than timeout limit, and then go on for next
> steps.
>
> You can't control the timeout with fopen(). Try looking at fsockopen().
> You can set a timeout for that.
I checked the manual. From the example, it is apparently that timeout only
works for the handle setup by fsockopen, but not for fsockopen itself.
Alex
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
>