OpenSwoole\Client::__construct

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Declaration

<?php OpenSwoole\Client::__construct ( $type, $async = null, $id = null )

Parameters

type

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

async

This field should always be empty.

id

The ID of the client.

Return

Description

Create a sync TCP/UDP client, with or without SSL.

Compile Swoole with enable-openssl or with-openssl-dir to support SSL. Also add OpenSwoole\Constant::SSL to the constructor.

Example

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);
Last updated on September 20, 2022