Join 4,000+ others and never miss out on new tips, tutorials, and more.
4.x is outdated, please check the latest version 22.x
Latest version:
pecl install openswoole-22.1.2
<?php Swoole\Coroutine\Http2\Client::__construct(string $host, int $port, bool $openSSL = false): Swoole\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 Swoole\Coroutine\Http2\Client
object.
The constructor for creating a new Swoole\Coroutine\Http2\Client
object.
If you need to set a timeout refer to the overall timeout guide.
When using SSL you must have installed Swoole with the --enable-openssl
flag and have OpenSSL installed on your server.
<?php
use Swoole\Coroutine\Http2\Client;
Co\run(function()
{
$client = new Swoole\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(Swoole\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)
}