php - Linux中的Rachet和命名管道
问题描述
我正在使用 Rachet 创建套接字,其中一种更新方法是写入命名管道 ( mkfifo filename
)
下面的代码有效
$server = IoServer::factory(
$application = new WebSocketApplication(),
8080
);
$updateFile = fopen('/tmp/testing', 'r');
$update = function ($stream) use ($application, $server, $u) {
$value = fread($stream, 8219);
$application->update($value);
//the line below is magic apparently, if this is removed, I end up in an infinite loop
fopen('/tmp/testing', 'r');
};
$server->loop->addReadStream($updateFile, $update);
$server->run();
这完全符合预期。我不知道为什么我需要第二条 fopen 线。
有人可以解释为什么需要它或者我做错了什么甚至需要这条线。
解决方案
推荐阅读
- python - 从非特权应用程序执行特权命令的正确方法
- vue.js - VueJS 和动态标题
- python - anaconda navigator 在加载应用程序时卡住了
- acumatica - 新实例忘记密码
- xamarin.forms - 如何让应用程序等到 OnAppearing 完成?
- python - 如何根据python中另一个Dataframe中的值更改Dataframe中的字段
- nsurlsession - nsurlsession 内部和后台传输
- tableau-api - 如何计算总数的百分比
- c# - 如何在文件持续更新时跟踪文件中的行号
- validation - Kotlin 验证 edittext 的条目和长度