Req #29990 [Opn->Csd]: Unbuffered fgets or fgetc function.

From: Date: Tue, 29 Oct 2013 08:11:21 +0000
Subject: Req #29990 [Opn->Csd]: Unbuffered fgets or fgetc function.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182472@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=29990&edit=1 ID: 29990 Updated by: krakjoe@php.net Reported by: louis at mulliemedia dot com Summary: Unbuffered fgets or fgetc function. -Status: Open +Status: Closed Type: Feature/Change Request -Package: Feature/Change Request +Package: *General Issues Operating System: Fedora PHP Version: Irrelevant -Assigned To: +Assigned To: krakjoe Block user comment: N Private report: N New Comment: This has nothing to do with being buffered or un-buffered. You are reading from a blocking stream; if you do not wish to block waiting for input them stream_set_blocking false on the handle. Closing the request. Previous Comments: ------------------------------------------------------------------------ [2004-09-05 23:49:46] louis at mulliemedia dot com 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 this bug report at https://bugs.php.net/bug.php?id=29990&edit=1

« previous php.bugs (#182472) next »