ID: 30154
User updated by: xxmettedraqxx at comcast dot net
Reported By: xxmettedraqxx at comcast dot net
Status: Wont fix
Bug Type: CGI related
Operating System: windows xp
PHP Version: 5.0.1
New Comment:
Well from what I've read now. This can only be done under Unix for
CLI..
I know php was not designed to be a web server language but it
certainly seems to be leaning in the direction of becoming a great way
to make something using sockets to serve just about anything. Possibly
even home made transfer protocols. That would be cool.
But as far as the STDIN, which I tried using a few times and I figured
the code below was more drawn out..
Now I'm trying to see if I can fake this out using socket streams and
the local connection to itself.. possibly even using stdin through a
socket create. I'm not sure yet.. still coding it out and testing a
few things.. and if I can find a way to help you guys (I can't navigate
web sites very well). I would code some c/c++ for the windows end of
things. I would love for this to be portable across windows also.
Thank you for your comment, I appreciate the help in any way, shape or
form that I can get it.
once again, thank you.
Mettedraq.
Previous Comments:
------------------------------------------------------------------------
[2004-09-20 17:29:34] [EMAIL PROTECTED]
win32 console doesn't work the same way as a unix tty, so if this
works, I'll be really surprised. The official line is that we're not
changing anything to make it happen at this time.
Secondly, you should be using the constant STDIN instead of
fopen('php://stdin') in PHP 5 and later.
------------------------------------------------------------------------
[2004-09-20 15:44:46] xxmettedraq at comcast dot net
function getStdI() {
static $pStdn, $pArr;
if(!$pStdn || !$pArr) {
$pStdn = fopen("php://stdin", "r");
$pArr = array($pStdn);
}
if (false === ($num_changed_streams = stream_select($pArr, $write =
NULL, $except = NULL, 0))) {
print("\$ 001 Socket Error : UNABLE TO WATCH STDIN.\n");
return FALSE;
} elseif ($num_changed_streams > 0) {
return fgets($pStdn, 1024);
}
} // end function getStdI
I found this on the internet..
stream_select fails for me so I'm assuming this is not possible under
windows even in version 5.0.1 of php and I'm going to try again under
cygwin.
If there is anything I can do to help code this bug/ability out. Let
me know. I know C/C++ and assembly but I am not familiar with the PHP
source code..
Thank you.
------------------------------------------------------------------------
[2004-09-19 16:35:07] xxmettedraqxx at comcast dot net
Description:
------------
I'm not sure if non-blocking mode works under windows xp..
I can't seem to process anything while waiting for user input.. it's
possible that I just do not know how to code this in php and it is my
fault. Although I searched for several days before posting this.
Can anyone help me out on this?
p.s. please email me if I don't respond.. I might loose track of this
bug if I'm not contacted in some way.
Thank you.
Reproduce code:
---------------
set_time_limit (0);
$fp_stdin = fopen("php://stdin", "rb");
stream_set_blocking($fp_stdin, false);
ob_implicit_flush ();
$input = get_line($fp_stdin);
function get_line($fp) {
$input = "";
$char = "";
do {
if (($char = @fread($fp,1)) !== false) {
$input .= $char;
if ($char == "\n") { break; }
$char = "";
} else {
echo "testing..\n";
}
} while(true);
return $input;
}; // end function get_line
Expected result:
----------------
I should be able to see the word testing until the user types
something.. as in.. say I typed in "shutdown"..
then the program would exit... after testing my input..
the testing is a substitute for checking telnet connections to allow
for user input from the keyboard and at the same time run through other
processes.
Actual result:
--------------
it waits for user input.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30154&edit=1