mirror of
https://github.com/danog/amp.git
synced 2024-11-27 04:24:42 +01:00
34bf671f13
Fixes #185.
22 lines
445 B
PHP
22 lines
445 B
PHP
#!/usr/bin/env php
|
|
<?php
|
|
|
|
require __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use Amp\Loop;
|
|
|
|
if (\stream_set_blocking(STDIN, false) !== true) {
|
|
\fwrite(STDERR, "Unable to set STDIN to non-blocking" . PHP_EOL);
|
|
exit(1);
|
|
}
|
|
|
|
print "Write something and hit enter" . PHP_EOL;
|
|
|
|
Loop::onReadable(STDIN, function ($watcher, $stream) {
|
|
$chunk = \fread($stream, 8192);
|
|
|
|
print "Read " . \strlen($chunk) . " bytes" . PHP_EOL;
|
|
});
|
|
|
|
Loop::run();
|