#44605 [Opn]: stream_select() does not work with fopen("php://output")

From: Date: Wed, 02 Apr 2008 09:39:32 +0000
Subject: #44605 [Opn]: stream_select() does not work with fopen("php://output")
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-655@lists.php.net to get a copy of this message
ID: 44605 User updated by: jc_mammana at hotmail dot com Reported By: jc_mammana at hotmail dot com Status: Open Bug Type: Documentation problem Operating System: Win32 PHP Version: 5.2.5 New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2008-04-02 09:27:25] jani@php.net And as php://output is special, of course stream_select() does not work with it. ------------------------------------------------------------------------ [2008-04-02 09:22:50] jani@php.net And of course I forgot that stdout != php://output :) ------------------------------------------------------------------------ [2008-04-02 09:18:02] 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 08:25:44] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44605&edit=1

« previous php.doc.bugs (#655) next »