Swoole\Client::connect — 连接到远端TCP或UDP端口。
说明
public Swoole\Client::connect(
string $host,
int $port = ?,
int $timeout = ?,
int $flag = ?
): bool
参数
host
远端地址的主机名。
port
远端地址的端口号。
timeout
connect/send/recv的超时时间(秒),默认为0.1s
flag
如果客户端类型为UDP,则$标志表示启用配置udp_connect。如果启用了配置udp_connect,客户端将只接收来自指定ip:port的数据。如果客户端类型为TCP,并且$标志设置为1,则在发送/接收之前必须使用swoole_client_select检查连接状态。
返回值
连接是否建立。