Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
<?php OpenSwoole\Coroutine\Http2\Client::__construct(string $host, int $port, bool $openSSL = false): OpenSwoole\Coroutine\Http2\Client
IP address of the remote host. You can also specify a full domain name here if needed.
The port number of the remote host you want to connect to.
If you want to enable support for SSL or not. Default is false
.
When successful it will return a OpenSwoole\Coroutine\Http2\Client
object.
The constructor for creating a new OpenSwoole\Coroutine\Http2\Client
object.
If you need to set a timeout refer to the overall timeout guide.
When using SSL you must have installed OpenSwoole with the --enable-openssl
flag and have OpenSSL installed on your server.
<?php
use OpenSwoole\Coroutine\Http2\Client;
co::run(function()
{
$client = new OpenSwoole\Coroutine\Http2\Client('127.0.0.1', 9518);
var_dump($client);
});
The above creation of the HTTP2 client will have these class properties:
<?php
object(OpenSwoole\Coroutine\Http2\Client)#3 (9) {
["errCode"]=>
int(0)
["errMsg"]=>
int(0)
["sock"]=>
int(-1)
["type"]=>
int(0)
["setting"]=>
NULL
["connected"]=>
bool(false)
["host"]=>
string(9) "127.0.0.1"
["port"]=>
int(9518)
["ssl"]=>
bool(false)
}