From:             [EMAIL PROTECTED]
Operating system: RedHat 7.3
PHP version:      4.3.0-pre1
PHP Bug Type:     Sockets related
Bug description:  fgets() returns garbage when STDIN set to non-blocking

I am trying to use the CLI version of 4.3.0-pre1.  My script needs to act
if there hasn't been input within a certain amount of time.  I've used the
following function to accomplish this with TCP/IPsockets in non-blocking
mode:

function GetSocketLine($socket, $timeout)
{
 $timeout += time();
 $holdString = "";
 while(time() < $timeout)
  {
  $string = fgets($socket, 1024);
  if($string != false)
    break;
  }
 return($string);
}

However, if I use set_stream_blocking() to set STDIN to non-blocking, the
above code returns garbage instead of "false" when there is nothing to
receive.  It would seem to me that if STDIN is set to non-blocking and
STDIN is passed to the above function as $socket, it ought to return
"false" when blocking would occur--it shouldn't return garbage.

-- 
Edit bug report at http://bugs.php.net/?id=19944&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=19944&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=19944&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=19944&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=19944&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=19944&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=19944&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=19944&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=19944&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=19944&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=19944&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=19944&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=19944&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=19944&r=isapi

Reply via email to