|  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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
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
From manual page:
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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-03 23:21 UTC]
-Status: Open +Status: Wont fix
 [2011-12-03 23:21 UTC]
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 

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 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 15 05:01:31 2024 UTC