#48472 [Com]: fgets/fread behaviour on socket timeout undocumented
| From: | nick dot telford at gmail dot com | Date: | Thu, 04 Jun 2009 16:28:29 +0000 |
| Subject: | #48472 [Com]: fgets/fread behaviour on socket timeout undocumented | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-2347@lists.php.net to get a copy of this message | ||
ID: 48472
Comment by: nick dot telford at gmail dot com
Reported By: nick dot telford at gmail dot com
Status: Open
Bug Type: Documentation problem
Operating System: CentOS 5.3
PHP Version: Irrelevant
New Comment:
Forgot to mention. Bug #31897 seems related but slightly different - as
it was fixed and closed when the docs about having to check
stream_get_meta_data() was added to stream_set_timeout().
Previous Comments:
------------------------------------------------------------------------
[2009-06-04 16:27:20] nick dot telford at gmail dot com
Description:
------------
When using stream_set_timeout() to set a timeout on a stream it is
documented that you need to check stream_get_meta_data() to see if the
stream timed out. However, the behaviour of fgets/fread (in blocking
mode) when the socket times out is not documented.
At first, I assumed that the time out would be considered a "failure",
which is documented in both fread and fgets as returning FALSE.
However, after testing, it appears that both methods return an empty
string when the socket times out. This is fine, because you can check to
see if this was because of an EOF (using feof) or a timeout
(stream_get_meta_data) after the method has returned.
The only problem here is a lack of descriptive documentation. The
behaviour of blocking read functions when the stream times out needs to
be documented as this is a common scenario when working with socket
streams.
Regards,
Nicholas Telford
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48472&edit=1