/** * Register a listener to be notified when a stream is ready to write. * * @param resource $stream The PHP stream resource to check. * @param callable $listener Invoked when the stream is ready. */ public function addWriteStream($stream, callable $listener) { $this->writeWatcherIDs[(int) $stream] = $this->reactor->onWritable($stream, function () use($listener, $stream) { return call_user_func($listener, $stream, $this); }); }