🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
~~~ 创建tcp服务器 1 关闭服务器防火墙(或者允许tcp连接) 注意放行端口 2 开启服务 $service = new swoole_server("0.0.0.0",9501); $service->set([ 'worker_num'=>1, 'max_request'=>10000, ]); $service->on('connect',function ($service,$fd,$reactor_id){ echo "Welcome to 四川 $service --- $reactor_id --- $fd \n" ; }); $service->on('receive',function ($service,$fd,$reactor_id,$data){ $service->send("$service say: $fd from $reactor_id you send $data \n"); }); $service->on('close',function ($service,$fd){ echo "$fd 离开 $service 关闭"; }); $service->start(); ~~~