是否可以使用Web套接字的本机PHP支持? [英] Is native PHP support for Web Sockets available?

查看:132
本文介绍了是否可以使用Web套接字的本机PHP支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找Web套接字实现的Hello World Type示例:

Looking for Hello World Type Example of Web Sockets Implementation:

这是套接字创建参考,但这看起来比Web套接字更低。

Here is Socket Create reference from php.net but this looks more low level than Web Sockets.

我想用这个 caniuse.com 上显示的Web套接字,现已在所有新的主流浏览器中实现。

I want to use this Web Sockets as shown here on caniuse.com which is now implemented in all new major browsers.

谷歌搜索出现了这个网队。 TutsPlus站点,我可以在其中使用JavaScript示例代码......但我需要知道如何在PHP中实现服务器端而不是Java,Ruby或Node.js,如示例所示。

A Google search turned up this Nets.TutsPlus site in which I can use the JavaScript example code...but I need to know how to implement the server-side in PHP not Java, Ruby, or Node.js as in the example.

PHP Socket Create是否相关? PHP本身是否支持Web套接字?我想在PHP实现的正确方向上的一点是有帮助的。

Is PHP Socket Create relevant? Does PHP natively support Web Sockets? I guess just a point in the right direction for PHP implementation would help.

实际上教程有一个到phpwebsockets的断开链接......这是应该使用的库吗?

Actually the tutorial has a broken link to phpwebsockets...is this the library one should use?

Websockets.org 有一个测试应用程序,但没有提到PHP。

Websockets.org has a test application, but no mention of PHP.

推荐答案

对于本机可用的标准PHP WebSocket对象,没有原生支持。

There isn't native support in terms of there being a standard PHP WebSocket object natively available.

您需要使用库。

接下来要考虑的是WebSocket服务器的运行方式。通常PHP运行在Apache,Nginx(通过FastCGI)或Microsoft IIS(通过快速CGI)。对于Apache和IIS,这可能是一个问题,因为它并没有真正构建持久连接,如WebSockets。我不确定Nginx。这就是为什么大多数PHP WebSocket库将作为独立库构建,以作为自己的进程运行。

The next thing to consider is how the WebSocket server runs. Normally PHP runs in Apache, Nginx (via FastCGI) or on Microsoft IIS (via Fast CGI). With Apache and IIS this may be a problem as it's not really built with persistent connections such as WebSockets in mind. I'm not sure about Nginx. This is why most PHP WebSocket libraries will be built as standalone libraries to be run as their own processes.

请参阅:

  • Apache Module: https://github.com/disconnect/apache-websocket
  • Ratchet: https://github.com/cboden/Ratchet
  • Wrench: https://github.com/varspool/Wrench
  • PHP WebSocket: http://code.google.com/p/phpwebsocket/

注意:IE10现已在Windows 8中发布

另见: Ajax推送系统

这篇关于是否可以使用Web套接字的本机PHP支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆