略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Swoole\Client::connect

2024-11-13

Swoole\Client::connect

(PECL swoole >= 1.9.0)

Swoole\Client::connectConnect to the remote TCP or UDP port.

说明

public Swoole\Client::connect(
    string $host,
    int $port = ?,
    int $timeout = ?,
    int $flag = ?
): bool

参数

host

The host name of the remote address.

port

The port number of the remote address.

timeout

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

flag

If the type of client is UDP, the $flag means if to enable the configuration udp_connect. If the configuration udp_connect is enabled, the client will only receive the data from specified ip:port. If the type of client is TCP and the $flag is set to 1, it must use swoole_client_select to check the connection status before send/recv.

返回值

Whether the connection is established.

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/swoole-client.connect.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3