对 Web 套接字的原生 PHP 支持是否可用?

Is native PHP support for Web Sockets available?(对 Web 套接字的原生 PHP 支持是否可用?)
本文介绍了对 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.

见:

  • Apache 模块:https://github.com/disconnect/apache-websocket
  • 棘轮:https://github.com/cboden/Ratchet
  • 扳手:https://github.com/varspool/Wrench
  • PHP WebSocket:http://code.google.com/p/phpwebsocket/

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

另见:Ajax推送系统

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

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)