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\Client::__construct ( $type, $async = null, $id = null )
The type of the client SWOOLE_SOCK_TCP
SWOOLE_SOCK_TCP6
SWOOLE_SOCK_UDP
SWOOLE_SOCK_UDP6
SWOOLE_SOCK_UNIX_DGRAM
, SWOOLE_SOCK_UNIX_STREAM
, SWOOLE_SSL
, SWOOLE_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 addSWOOLE_SSL
to the constructor.
Establish a SSL connection.
<?php
$client = new Swoole\Client(SWOOLE_SOCK_TCP | SWOOLE_SSL);
Create persistent TCP connection:
<?php
$client = new Swoole\Client(SWOOLE_TCP | SWOOLE_KEEP);