<?php public function __construct($clientType)
The type of the client to create, see constants below.
A new TCP/UDP client instance.
Create a coroutine TCP/UDP client within a coroutine context, with or without SSL.
Compile Swoole with
with-openssl-dir to support SSL. Also add
SWOOLE_SSL to the constructor.
You can use the following client types when creating a new TCP/UDP client.
To establish an SSL connection.
<?php $client = new Swoole\Coroutine\Client(SWOOLE_SOCK_TCP | SWOOLE_SSL); ...
To create persistent TCP connection:
<?php $client = new Swoole\Coroutine\Client(SWOOLE_TCP | SWOOLE_KEEP); ...
A persistent connection created by using
SWOOLE_KEEP will not be closed, even when calling
$client->close(). This makes it easier when having to reconnect again after the server disconnects or an error happens, the connection details are saved. The client deconstructor will handle any connection closing when using