Re: nonblocking STDIN in CLI PHP app



I think this is a better way to approach my question. Here's my
script:

<?php
$stdin = fopen('php://stdin', 'r');

stream_set_blocking($stdin, false);

$last_date = '';
while (true)
{
fread($stdin, 1024);
if ($last_date != date('g:ia'))
{
$last_date = date('g:ia');
echo "The time is now [$last_date]\r\n";
}
}

If I comment out the fread, it echo's the time once a minute. If I
leave the fread as it is, it doesn't. My question is... why?
Blocking is set to false, so why does it appear to be blocking, anyway?

.



Relevant Pages

  • Re: nonblocking STDIN in CLI PHP app
    ... If I comment out the fread, it echo's the time once a minute. ... Blocking is set to false, so why does it appear to be blocking, anyway? ...
    (comp.lang.php)
  • Re: [PHP] Limiting repetitive file access
    ... >repetitively entering the same url repetitively ... Sessions won't work unless the script at the other end is co-operating by ... and assholes seem to have infinite free time. ... You could also try blocking if a referer: ...
    (php.general)
  • Re: script problem
    ... your calling syntax requires that this script either takes arguments ... This can happen because there is a script fread and a function fread ... You may use the command: ... your filename contains invalid characters. ...
    (comp.soft-sys.matlab)
  • Re: Norton blocks ASP.NET mails!
    ... antivirus programs inc. Norton & McAffe run a utility called script ... cript blocking prevents calls to the File System Object. ... means that if you have script blocking enabled on your antivirus then ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: code red attacks and real-time blackholeng
    ... code red attacks and real-time blackhole'ng ... Description: A nice PHP script and bash script that will, every five minutes, ... > 1) the above port 80 blocking makes sense if tcp and udp are blocked or is ...
    (Incidents)