ID: 50856 Comment by: info at netzkontrast dot com Reported By: info at netzkontrast dot com Status: Feedback Bug Type: Streams related Operating System: Ubuntu/Suse/Linux PHP Version: 5.3.1 New Comment:
i think it's interesting to mention that stream_set_blocking($stream, 0) returns true... i did poke around a bit in streamsfuncs.c on line 1321 (and plain_wrapper.c line 559ff) - and if i'm interpreting it correct. returning truly means that the o_NONBLOCK-flag gets correctly set at the corresponding open-command. right now i'm not sure were to look next. Think i need to read a lot more code ,-) Previous Comments: ------------------------------------------------------------------------ [2010-01-28 15:55:08] info at netzkontrast dot com fopen is still blocking with local files ('wrapper_type' => string 'plainfile' and URL's 'wrapper_type' => string 'cURL' looks like stream_set_blocking gets totaly ignored from fopen while non_blocking reads still work with fsockopen, and reading from STDIN ------------------------------------------------------------------------ [2010-01-28 08:45:08] j...@php.net Please try using this snapshot: http://snaps.php.net/php5.3-latest.tar.gz For Windows: http://windows.php.net/snapshots/ ------------------------------------------------------------------------ [2010-01-27 09:32:09] info at netzkontrast dot com there is a typo in streamFsockTest.php instead of: fputs($handle, "GET /streamcontent.php HTTP/1.0\r\nHost: mp.devel\r\nConnection: keep-alive\r\n\r\n"); it should be: fputs($handle, "GET /streamcontent.php HTTP/1.0\r\nHost: localhost\r\nConnection: keep-alive\r\n\r\n"); ------------------------------------------------------------------------ [2010-01-27 09:28:21] info at netzkontrast dot com Description: ------------ I tried the following code with different PHP-versions (5.3.1 + 5.2.8) on different Systems (one ubunto-box and a suse-box i'm totaly stuck, is there anything i'm missing? -- i have prepared some testscripts - streamContent.php (used for testoutput) - streamfiletest.php -> not working - streamSocketTest.php -> not working - streamFsockTest.php -> working Reproduce code: --------------- <?php // streamfiletest.php $filename = "/home/tests/myfile.txt"; $handle = fopen($filename, "r"); stream_set_blocking($handle, 0); $metadata = stream_get_meta_data($handle); var_dump($metadata['blocked']) // should return 0 ?> <?php // streamContent.php for($i = 10;$i;--$i) { echo ". "; if (ob_get_contents())ob_flush();flush();usleep(1000000); } ?> <?php //streamSocketTest.php $handle = fopen("http://localhost/streamContent.php", "r"); stream_set_blocking($handle, 0); while(!feof($handle)) { echo fread($handle, 100); echo "-";usleep(80000); } ?> <?php // streamFsockTest.php $handle = fsockopen("localhost", 80); stream_set_blocking($handle, 0); fputs($handle, "GET /streamcontent.php HTTP/1.0\r\nHost: mp.devel\r\nConnection: keep-alive\r\n\r\n"); while(!feof($handle)) { echo fgets($handle, 10); echo "-";usleep(80000); }?> Expected result: ---------------- streamfiletest.php: 0 streamSocketTest.php: . -----------. ------------. (etc..) streamFsockTest.php: . -----------. ------------. (etc..) Actual result: -------------- streamfiletest.php: 1 streamSocketTest.php: . -. -. - streamFsockTest.php: . -----------. ------------. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50856&edit=1