“慢生活”不是懒惰,放慢速度不是拖延时间,而是让我们在生活中寻找到平衡。网站首页程序人生
workerman利用属性connections遍历向客户端定时发消息
发布时间:2021-11-30 22:12:17作者:雪饮
![[!--pagekey--]](/e/data/images/notimg.gif)
connections存储了当前进程的所有的客户端连接对象,其中id为connection的id编号。如果得知connection的编号为$id,可以很方便的通过$worker->connections[$id]获得对应的conn
阅读全文>>workerman利用logFile属性指定自身运行日志存储路径(不包含业务日志)
发布时间:2021-11-30 22:11:17作者:雪饮
![[!--pagekey--]](/e/data/images/notimg.gif)
logFile说明:static string Worker::$logFile用来指定workerman日志文件位置。此文件记录了workerman自身相关的日志,包括启动、停止等。如果没有设置,文件名默认为workerman
阅读全文>>workerman端口复用reusePort属性实现同一个入口监听多个协议及端口
发布时间:2021-11-29 23:00:21作者:雪饮
![[!--pagekey--]](/e/data/images/notimg.gif)
这个就很有意思了像是下面这样,同一个入口文件,既能处理text协议,也能处理http协议:start.php:<?phpuse Workerman\Worker;use Workerman\Connection\TcpConnection;require_on
阅读全文>>workerman端口复用reusePort属性
发布时间:2021-11-29 22:52:55作者:雪饮
![[!--pagekey--]](/e/data/images/notimg.gif)
要求(workerman >= 3.2.1 并且 PHP>=7.0)这两个要求,我都满足,我这里是workerman4系列,php7.3.4设置当前worker是否开启监听端口复用(socket的SO_REUSEPORT选项)。开启监听端口复
阅读全文>>workerman只在指定进程运行的定时器
发布时间:2021-11-29 21:42:37作者:雪饮
![[!--pagekey--]](/e/data/images/notimg.gif)
test.php:<?phpuse Workerman\Worker;use Workerman\Lib\Timer;require_once __DIR__ . '/vendor/autoload.php'; $worker = new Worker('tcp://0.0.0.0:8585');$worker->c
阅读全文>>