对 Web 套接字的原生 PHP 支持是否可用? [英] Is native PHP support for Web Sockets available?

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

问题描述

寻找 Web Sockets 实现的 Hello World 类型示例:

Looking for Hello World Type Example of Web Sockets Implementation:

这是来自 php.net 的 Socket Create 参考,但这看起来更底层比网络套接字.

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.

Google 搜索发现了这个 Nets.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 Sockets?我想 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(通过 Fast 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.

见:

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

另见:Ajax推送系统

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

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