dongxu2398 2012-04-25 01:34
浏览 192

没有守护进程的PHP中的WebSocket服务器?

I will try to make my first post here as interesting as possible.

Lately I have been interested in the feasibility of handling WebSocket requests on a shared hosting server.

Please don't tell me "upgrade your plan". All this would be trivial on at least a VPS. I realize that.

As many know, shared hosts will...

  • Kill a daemon if they see one
  • Block usage of server sockets
  • Deny you shell access
  • Keep apache off limits (no module installations)

These restrictions eliminate phpwebsocket, python altogether. A no-daemon solution that masquerades as a web page is needed.

PHP being my favorite server-side language, I crafted a PHP websocket gateway posing as a web page.

So far I have been successful in sending the right headers for the handshake and streaming output (using output buffering), but I still can't figure out how to continue to read data after the initial request.

In short, I want to continue to receive data from the client even after the PHP script is started. I have tried reading the php://input pseudofile, but I can't seem to get any more reads out of it after the end of the GET. Is there any setting or hack that will allow this?

Thanks!

  • 写回答

3条回答 默认 最新

  • duanjunao9348 2012-04-28 07:12
    关注

    After the WebSocket handshake is done, it works pretty much like regular sockets. There is no reason why Apache would allow unidirectional communication without headers.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?