doudizhu2222 2011-04-18 13:19
浏览 250

PHP异步读取(shell脚本)

I have a PHP TCP daemon which provides data to clients. One of the features is to get info from "tail -f messages" command. So I have to run this command asynchronously and in case of new data, send it to the clients.

I have a problem how to create this asynchronous reader - when new data is added, run the method, otherwise do the other things you have to.

Mejmo

EDIT: My problem could be resolved by using some kinds of threads and IPC (does php support threads?).

  • 写回答

3条回答 默认 最新

  • doulu7174 2011-04-18 13:31
    关注

    Use popen to execute tail -f message, passing 'r' as the $mode parameter. Then you can fread from the returned file pointer.

    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建