stream_set_blocking

Supported Versions: PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8
Set blocking/non-blocking mode on a stream
stream_set_blocking(resource $streambool $enable): bool
require __DIR__ '/../vendor/autoload.php';



if (!
defined('STDIN') || stream_set_blocking(STDINfalse) !== true) {

    
fwrite(STDERR'ERROR: Unable to set STDIN non-blocking (not CLI or Windows?)' PHP_EOL);

    exit(
1);

}
    if ($chunk === '') {

        
Loop::removeReadStream($stream);

        
stream_set_blocking($streamtrue);

        
fclose($stream);

        return;

    }
$data str_repeat($dataround(200000 strlen($data)));



if (!
defined('STDOUT') || stream_set_blocking(STDOUTfalse) !== true) {

    
fwrite(STDERR'ERROR: Unable to set STDOUT non-blocking (not CLI or Windows?)' PHP_EOL);

    exit(
1);

}
    if ($r === 0) {

        
Loop::removeWriteStream($stdout);

        
fclose($stdout);

        
stream_set_blocking($stdouttrue);

        
fwrite(STDERR'Stopped because STDOUT closed' PHP_EOL);



        return;
if (!$stream) {

    exit(
1);

}

stream_set_blocking($streamfalse);




fwrite($stream"GET / HTTP/1.1\r\nHost: www.google.com\r\nConnection: close\r\n\r\n");
if (!$stream) {

    exit(
1);

}

stream_set_blocking($streamfalse);




echo 
'Connecting';
if (!$server) {

    exit(
1);

}

stream_set_blocking($serverfalse);




Loop::addReadStream($server, function ($server) {
    public function testRemoveReadAndWriteStreamFromLoopOnceResourceClosesEndsLoop()

    {

        list(
$stream$other) = $this->createSocketPair();

        
stream_set_blocking($streamfalse);

        
stream_set_blocking($otherfalse);
    {

        list(
$stream$other) = $this->createSocketPair();

        
stream_set_blocking($streamfalse);

        
stream_set_blocking($otherfalse);




        
$this->loop->addWriteStream($stream, function () { });
    public function testRemoveReadAndWriteStreamFromLoopOnceResourceClosesOnEndOfFileEndsLoop()

    {

        list(
$stream$other) = $this->createSocketPair();

        
stream_set_blocking($streamfalse);

        
stream_set_blocking($otherfalse);
    {

        list(
$stream$other) = $this->createSocketPair();

        
stream_set_blocking($streamfalse);

        
stream_set_blocking($otherfalse);




        
$this->loop->addWriteStream($stream, function () { });
    {


        list(
$stream) = $this->createSocketPair();

        
stream_set_blocking($streamfalse);




        
$this->loop->addWriteStream($stream, function () { });