Skip to content

Commit 35417eb

Browse files
committed
add stream_set_blocking for of type stream to limit boilerplate for creating non-blocking io
1 parent b5d221c commit 35417eb

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/Stream.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ class Stream extends EventEmitter implements DuplexStreamInterface
1818
public function __construct($stream, LoopInterface $loop)
1919
{
2020
$this->stream = $stream;
21+
if (get_resource_type($this->stream) === "stream") {
22+
stream_set_blocking($this->stream, 0);
23+
}
24+
2125
$this->loop = $loop;
2226
$this->buffer = new Buffer($this->stream, $this->loop);
2327

0 commit comments

Comments
 (0)