From:             louis at mulliemedia dot com
Operating system: Fedora
PHP version:      Irrelevant
PHP Bug Type:     Feature/Change Request
Bug description:  Unbuffered fgets or fgetc function.

Description:
------------
Hello,

First of all I'd like to thank all of you PHP community for your
commitment to PHP. This is what makes PHP the best web scripting language
on earth. If I could code this function in C, I would, however at this
moment I am only a begginner in C/C++ thats why I am posting here :)

Some applications (in my case, a socket server) wich have to be run from
the command line and will run forever, need to have some administration
functions from the CLI so that you can create basic functions (like
shutdown, etc.)

I think that an unbuffered fgetc or fegts function would be very nice so
that we can read from php://stdin only if there is something to read, and
so that it doesnt hang there waiting for input.

I'd like to give a few urls of other people in need of this, as I might
not have explained properly :
http://lists.nyphp.org/pipermail/talk/2003-September/005595.html
http://www.phpbuilder.com/lists/php-developer-list/2001121/1771.php

Thanks,

Louis

Reproduce code:
---------------
        function getStdI() {
        
            static $pStdn;
            
            if(!$pStdn)
            {
                $pStdn = fopen("php://stdin", "r");
            }

                return trim(fgets($pStdn, 1024));
        }

while(1) {
 getStdI(); // will hang there until enter is pressed
 // socket server code
}


-- 
Edit bug report at http://bugs.php.net/?id=29990&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=29990&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=29990&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=29990&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=29990&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=29990&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=29990&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=29990&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=29990&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=29990&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=29990&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=29990&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=29990&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=29990&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=29990&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=29990&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=29990&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=29990&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=29990&r=float

Reply via email to