php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #60273 stream-set-timeout not clear about how it works and how it should be used
Submitted: 2011-11-11 19:50 UTC Modified: 2011-12-03 23:21 UTC
From: ibaldo at adinet dot com dot uy Assigned:
Status: Wont fix Package: Documentation problem
PHP Version: trunk-SVN-2011-11-11 (SVN) OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ibaldo at adinet dot com dot uy
New email:
PHP Version: OS:

 

 [2011-11-11 19:50 UTC] ibaldo at adinet dot com dot uy
Description:
------------
---
From manual page: http://www.php.net/function.stream-set-timeout#refsect1-function.stream-set-timeout-description
---
It is not clear to me if it refers to a timeout since the last byte received from the stream or a timeout since the stream has been opened.
For example, if I set a timeout of 5 seconds with this function, if I receive data without problems, will it stop at 5 seconds even if I am receiving data? Or will it stop after not receiving data for 5 seconds?
And, what is the default timeout?
Also, some people say that you should call it everytime after a fwrite otherwise the fread will not timeout.
Other people say that before doing the fread one should check the timed_out field of the array returned by stream_get_meta_data.
Someone with the right knowledge should improve the documentation substantially since its not clear at all.
The example should be done with a loop to show people how to read correctly with timeout handling in a loop since fread can bring less data than there is really available or requested.
Thanks.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-03 23:21 UTC] frozenfire@php.net
-Status: Open +Status: Wont fix
 [2011-12-03 23:21 UTC] frozenfire@php.net
I can appreciate that some people may not understand this function if they're 
not familiar at all with streams, but the concept of a stream timeout is fairly 
well-established for those who've used them before in any language.

The set stream timeout is how long an operation will wait when reading, before 
it gives up. There's no ambiguity about that. It's relative to when you call the 
read.

As for the default, I'm somewhat certain that the default timeout on sockets is 
set by your system. There's no default set by PHP itself, that I'm aware of.

In any case, these are not things that need to be discussed on this function's 
reference.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 03:01:28 2024 UTC