UDP
UDP
为应用程序提供了一种无需建立连接就可以发送封装的IP
数据包的方法。
EasySwooleEvent
中mainServerCreate事件,进行子服务监听:
public static function mainServerCreate(\EasySwoole\EasySwoole\Swoole\EventRegister $register)
{
$server = \EasySwoole\EasySwoole\ServerManager::getInstance()->getSwooleServer();
$subPort = $server->addlistener('0.0.0.0', 9503, SWOOLE_UDP);
$subPort->on($register::onPacket, function (\Swoole\Server $server, string $data, array $clientInfo) {
$server->sendto($clientInfo['address'], $clientInfo['port'], 'Server:' . $data);
});
}
当前内容版权归 EasySwoole 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 EasySwoole .