<?php //创建异步tcp客户端 $client = new swoole_client(SWOOLE_SOCK_TCP,SWOOLE_SOCK_ASYNC); //注册链接成功的回调 $client->on('connect',function($cli){ $cli->send("hello\n"); }); //注册数据接收 $cli : 服务端信息$data 数据 $client->on("receive",function($cli,$data){ echo "data:$data"; }); //注册链接失败 $client->on("error",function($cli){ echo "失败\n"; }); //注册关闭函数 $client->on('close',function($cli){ echo "关闭\n"; }); //发起链接 $client->connect("192.168.50.1",8080,10);
php-swoole异步tcp客户端
最新推荐文章于 2024-08-11 22:36:11 发布