server:
<?php
//tcp服务器
class Server
{
private $serv;
public function __construct()
{
$this->serv = new Swoole\Server('0.0.0.0', 1216);
$this->serv->set([
'worker_num' => 10,
'deamonize' => true,
]);
//增加新的监控的ip:post:mode
$this->serv->addlistener("0.0.0.0", 2345, SWOOLE_SOCK_TCP);
$this->serv->on('Start', array($this, 'onStart'));
$this->serv->on('Connect', array($this, 'onConnect'));
$this->serv->on('Receive', array($this, 'onReceive'));
$this->serv->on('Close', array($this, 'onClose'));
//master进程启动后, fork出Manager进程, 然后触发ManagerS
swoole的TCP协议c/s架构
最新推荐文章于 2024-07-02 15:24:01 发布