問題描述
尋找 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 支持是否可用?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!