Re: re:Timing out an fgets
| From: | David Robley | Date: | Fri, 18 Aug 2000 04:15:31 +0000 |
| Subject: | Re: re:Timing out an fgets | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-12402@lists.php.net to get a copy of this message | ||
On 18 Aug, Joseph H Blythe wrote:
> David Robley wrote:
>
>> > Yes I am wrong should be set_time_limit()
>> >
>> > But for some reason the max_execution_time variable in the php.ini is not
>> > working as my script will sit there for 5 mins trying to receive the fgets,
>> > this is why I originally was trying to timeout the fgets function, until I
>> > found that I could possibly timeout the whole script and take measures to
>> > recover from this situation.
>> >
>> > Yes the fsockopen timeout is functional, and there is no problem opening the
>> > socket, just the application I am connecting too is set not to return a
>> > response, so when I call fgets it just keeps going until the actual page times
>> > out, at least I am pretty sure of this.
>> >
>> > Thanks for your thoughts, I might try setting the timeout again to see what
>> > happens.
>> >
>> > Cheers,
>> >
>> > Joseph Blythe
>>
>> Maybe max_execution_time is related to cpu usage or user time, rather
>> than 'real' time, and because your script isn't doing anything but wait
>> on an external process, the timer is off? More theorising.
>
> Hmm, I am pretty sure it is based on seconds from the servers clock?
>
> consider the following code.
>
> set_time_limit(30);
>
> while( connection_timeout() == "FALSE" ) {
> fgets($fp, 1024)
> or die("Error no response recieved");
> if ( connection_timeout() == "TRUE" ) {
> die("Connection timed out");
> }
> }
>
> When I try this in my script it jumps straight to TRUE and says 'Connection timed
> out' this is in like 1 second, so I really don't get it, further more if the
> max_execution_time was working the timeout should be 1 minute as per the manual
> because as far as I can tell the set_time_limit is added to the max_execution_time.
>
> Am I using this right anyone?
Remember that (the string) "TRUE" is not the same as (boolean) TRUE. You
can check the boolean value of the response from connection_timeout just
by doing if (connection_timeout() ).
Cheers
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA