*/ public static function connect(string $uri, int $timeout = 0, int $attempts = 0, bool $noDelay = false): Promise { return call(function () use ($uri, $timeout, $attempts, $noDelay): \Generator { $context = new ConnectContext(); if ($timeout > 0) { $context = $context->withConnectTimeout($timeout); } if ($attempts > 0) { $context = $context->withMaxAttempts($attempts); } if ($noDelay) { $context = $context->withTcpNoDelay(); } $context = $context->withTlsContext( (new ClientTlsContext('')) ->withoutPeerVerification(), ); return new self(yield connect($uri, $context)); }); } /** * @psalm-return Promise */ public function read(): Promise { return $this->socket->read(); } /** * @psalm-return Promise */ public function write(string $data): Promise { return $this->socket->write($data); } /** * {@inheritDoc} */ public function close(): void { $this->socket->close(); } /** * @psalm-return Promise */ public function setupTls(): Promise { return $this->socket->setupTls(); } }