ID:          29942
 Updated by:  [EMAIL PROTECTED]
 Reported By: jon at foneport dot com
-Status:      Open
+Status:      Closed
 Bug Type:    Documentation problem
 PHP Version: Irrelevant
 New Comment:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation
better.




Previous Comments:
------------------------------------------------------------------------

[2004-09-02 00:45:40] jon at foneport dot com

Description:
------------
The documentaion for feof function seems contradictory. It seesm to
suggest that the normal behaviour on a socket timeout is to cause feof
to return TRUE and that calling stream_set_timeout() changes the
behaviour of feof to cause it to instead return FALSE on timeout. From
useage experience with various versions of PHP, feof only returns TRUE
on a socket if the connection has closed, whether or not
stream_set_timeout() has been called makes no difference to the
behaviour of feof(). This seems sensible as getting feof to return
FALSE on timeout would not help prevent anyone getting into a long
while loop while testing feof. It seems that the way things actually
work are correct whereas the documention is a little confusing or
misleading.

>From the documentation 

"Returns TRUE if the file pointer is at EOF or an error occurs
(including socket timeout); otherwise returns FALSE."

"Warning

feof() will return TRUE only if the connection opened by fsockopen() is
closed. This can cause a script to timeout. The workaround for this is
to use stream_set_timeout(), so that feof() will return FALSE on
timeout. "

Reproduce code:
---------------
stream_set_timeout($fp, 5); 
             
                                                                       
                                                     
while(!feof($fp)) { // until connection is closed or timed 
                $status = socket_get_status($fp);
     
                $data[] = fgets($fp, 1000);
                $status = socket_get_status($fp); 
                                                                       
                                                                        
                                                                        
                                                       
                }

This will loop until disconnected.
$status['timed_out'] get set to 1 and feof continues to return false.
This occurs whether I set stream_set_timeout or not. The behaviour of
feof() is unchanged.




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=29942&edit=1

Reply via email to