OpenSwoole\Client->enableSSL

25.x is outdated, please check the latest version 26.x


Latest version: pecl install openswoole-26.2.0

Declaration

<?php OpenSwoole\Client->enableSSL()

Parameters

Return

Description

Enable SSL support.

If the client hasn't enabled the SSL in the constructor and has connnected to the server, you can enable the SSL for the TCP client with this method.

Example

<?php
$client = new OpenSwoole\Client(OpenSwoole\Constant::SOCK_TCP);
if (!$client->connect('127.0.0.1', 9501, -1))
{
    exit("connect failed. Error: {$client->errCode}\n");
}
$client->send("hello world\n");
echo $client->recv();

if ($client->enableSSL())
{
    $client->send("hello world\n");
    echo $client->recv();
}
$client->close();
Last updated on February 28, 2026