php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #44605 stream_select() does not work with fopen("php://output")
Submitted: 2008-04-02 08:25 UTC Modified: 2010-01-13 03:04 UTC
From: jc_mammana at hotmail dot com Assigned: kalle (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.2.5 OS: Win32
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: jc_mammana at hotmail dot com
New email:
PHP Version: OS:

 

 [2008-04-02 08:25 UTC] jc_mammana at hotmail dot com
Description:
------------
This code gave me an error : 

# $stdout = fopen("php://output", "wb" );
# (...)
# $sw = array($stdout);
# $sr = $se = NULL;
# $r = stream_select($sr, $sw, $se, 3); 
# fwrite($stdout, "hello php world!" );
# flush();

So there is no way to detect if the client is able to receive data (in case of non gracefully disconnection).

Expected result:
----------------
stream_select should return 0 (for timeout reason) if the client is disconnected.

Actual result:
--------------
PHP ERROR : cannot represent a stream of type Output as a select()able descriptor

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-02 09:18 UTC] jani@php.net
It works fine with the "stock" STDOUT but not when you open the thing "manually". This works (or at least does not give me any errors :) 

<?php
 $sw = array(STDOUT);
 $sr = $se = NULL;
 $r = stream_select($sr, $sw, $se, 3); 
 fwrite(STDOUT, "hello php world!" );
 flush();
?>
 [2008-04-02 09:22 UTC] jani@php.net
And of course I forgot that stdout != php://output :)
 [2008-04-02 09:27 UTC] jani@php.net
And as php://output is special, of course stream_select() does not work with it.
 [2008-04-02 09:39 UTC] jc_mammana at hotmail dot com
I understand the difference between php://output and php://stdout (or STDOUT).
In case of php is used as webserver module, we have to use "php://output" and there is no way to know if the client has received the buffer.

connection_status() is able to tell us the TCP connection state but there is no solution to get/set this TCP timeout.
 [2010-01-13 03:04 UTC] svn@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=293482
Log: Fixed bug #44605 (stream_select() does not work with fopen("php://output"))
 [2010-01-13 03:04 UTC] kalle@php.net
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.


 [2020-02-07 06:09 UTC] phpdocbot@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=a0bcdcf6eaf5be3342b8f692200fe1d27f370238
Log: Fixed bug #44605 (stream_select() does not work with fopen(&quot;php://output&quot;))
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Jun 17 07:00:02 2026 UTC