OpenSwoole\Client->connect

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

Declaration

<?php OpenSwoole\Client->connect(string $host, int $port = null, float $timeout = 0.1, int $sock_flag = null)

Parameters

host

Host name or IP of the remote server

port

Port of the remote server

timeout

The timeout(second) of connect/send/recv, the dafault value is 0.1 second

sock_flag

Host name or IP of the remote server

Return

Description

Establish the connection.

Example

<?php
if ($cli->connect('127.0.0.1', 9501)) {
    $cli->send("data");
} else {
    echo "connect failed.";
}
Last updated on September 1, 2022