|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-01-27 09:28 UTC] 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: . -----------. ------------.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 05:00:01 2025 UTC |
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