Re: Re: STDIN Stream Query

From: Date: Fri, 17 Aug 2007 15:15:36 +0000
Subject: Re: Re: STDIN Stream Query
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-260965@lists.php.net to get a copy of this message
Jason Freeman wrote: > Per Jessen wrote: >> >> When a file descriptor (stdin) is non-blocking, any read() will not >> block and wait for data to become available, but will return right >> away with or without data. Set the fd to blocking to wait for data. >> > > This is true which is why I put fread() into a loop. If you look at > the output you will see that data is available even before the first > iteration. PHP only seems to recognize this though when the enter key > is pressed. If I press the enter key while blocking is off then it > finds the data. Is there any way to get the PHP to recognize that data > is available without pressing the enter key? So you want to read from stdin byte for byte? If so, I suspect your problem is in the normal stream buffering. I don't know if terminal IO is really feasible with PHP. Maybe you should check out the ncurses interface? /Per Jessen

« previous php.general (#260965) next »