<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/12/26
* Time: 16:58
*/
异步tcp
创建tcp客户端
//创建Client对象,连接 127.0.0.1:9501端口
$client = new swoole_client(SWOOLE_SOCK_TCP); //判断连接是否成功
if (!$client->connect('192.168.229.1', 8080, -1))
{
exit("connect failed. Error: {$client->errCode}\n");
} //发送数据接收事件
$client->send("hello world"); //输出服务返回参数
echo $client->recv(); //连接关闭
$client->close();
报错结果