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\Client::__construct ( $type, $async = null, $id = null )
The type of the client OpenSwoole\Constant::SOCK_TCP
OpenSwoole\Constant::SOCK_TCP6
OpenSwoole\Constant::SOCK_UDP
OpenSwoole\Constant::SOCK_UDP6
OpenSwoole\Constant::SOCK_UNIX_DGRAM
, OpenSwoole\Constant::SOCK_UNIX_STREAM
, OpenSwoole\Constant::SSL
, OpenSwoole\Constant::KEEP
This field should always be empty.
The ID of the client.
Create a sync TCP/UDP client, with or without SSL.
Compile Swoole with
enable-openssl
orwith-openssl-dir
to support SSL. Also addOpenSwoole\Constant::SSL
to the constructor.
Establish a SSL connection.
<?php
$client = new OpenSwoole\Client(OpenSwoole\Constant::SOCK_TCP | OpenSwoole\Constant::SSL);
Create persistent TCP connection:
<?php
$client = new OpenSwoole\Client(OpenSwoole\Constant::TCP | OpenSwoole\Constant::KEEP);