Ok, from suggestion at another post here in this journal, i've been messing around with the stream_select function, and so far, i've only gotten STDIN or php://stdin to work 1 time and actually read.
What the heck am I doing wrong?
$stdin=fopen("php://stdin","r");
$desc=array(
array("pipe","r"),
array("pipe","w"),
array("file","err","a")
);
proc_open("mpg123 -R",$desc,$mpg);
$read=array($mpg[1],$stdin);
while (stream_select($read,$write=null,$error=n ull,0,200000) !== FALSE) {
foreach($read as $streamnum => $resource) {
if ($streamnum == 0) {
echo "We got something from the application! ".fgets($resource);
}
if ($streamnum == 1) {
echo "We got something from you, the user! ".fgets($resource);
}
}
}
I have no friggin idea what's going wrong with this code, anytime i type something in i see nothing, it's getting on my friggin nerves. The application sends stuff back JUST fine. I see one problem with my code, is it only going to trigger the first streamnum, 0, unless both the application and the user input something, well, i don't even see anything then. HELP!
What the heck am I doing wrong?
$stdin=fopen("php://stdin","r");
$desc=array(
array("pipe","r"),
array("pipe","w"),
array("file","err","a")
);
proc_open("mpg123 -R",$desc,$mpg);
$read=array($mpg[1],$stdin);
while (stream_select($read,$write=null,$error=n
foreach($read as $streamnum => $resource) {
if ($streamnum == 0) {
echo "We got something from the application! ".fgets($resource);
}
if ($streamnum == 1) {
echo "We got something from you, the user! ".fgets($resource);
}
}
}
I have no friggin idea what's going wrong with this code, anytime i type something in i see nothing, it's getting on my friggin nerves. The application sends stuff back JUST fine. I see one problem with my code, is it only going to trigger the first streamnum, 0, unless both the application and the user input something, well, i don't even see anything then. HELP!
