Swoole\Coroutine\Client::__construct

Declaration

<?php
Swoole\Coroutine\Client::__construct ( $type )

Parameters

type

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

Return

Description

Create a coroutine TCP/UDP client within a coroutine context, with or without SSL.

Compile Swoole with enable-openssl or with-openssl-dir to support SSL. Also add SWOOLE_SSL to the constructor.

Example

Establish a SSL connection.

<?php
$client = new Swoole\Coroutine\Client(SWOOLE_SOCK_TCP | SWOOLE_SSL);

Create persistent TCP connection:

<?php
$client = new Swoole\Coroutine\Client(SWOOLE_TCP | SWOOLE_KEEP);