<?php
namespace process;
use Workerman\Worker;
class WorkermanTcpService
{
public function onWorkerStart()
{
// 创建一个 TCP Worker 监听指定端口
$tcp_worker = new Worker('tcp://0.0.0.0:2345');
$tcp_worker->onWorkerStart = function (Worker $worker) {
echo "Worker {$worker->id} starting...\n";
};
// 当有客户端连接时触发
$tcp_worker->onConnect = function ($connection) {
echo "New connection\n";
};
// 当接收到数据时触发
$tcp_worker->onMessage = function ($connection, $data) {
// 处理接收到的数据
$connection->send('Received: ' . $data);
};
// 当连接关闭时触发
$tcp_worker->onClose = function ($connection) {
echo "Connection closed\n";
};
Worker::runAll();
}
}
启动后一直狂闪,
https://www.workerman.net/doc/workerman/worker/listen.html
我是在webman的process中创建应该怎么做呢
狂闪什么 贴出来信息