問題描述
尋找 Web Sockets 實(shí)現(xiàn)的 Hello World 類型示例:
Looking for Hello World Type Example of Web Sockets Implementation:
這是來自 php.net 的 Socket Create 參考,但這看起來更底層比網(wǎng)絡(luò)套接字.
Here is Socket Create reference from php.net but this looks more low level than Web Sockets.
我想在 caniuse.com 上使用此 Web 套接字,現(xiàn)在已在所有新專業(yè)中實(shí)現(xiàn)瀏覽器.
I want to use this Web Sockets as shown here on caniuse.com which is now implemented in all new major browsers.
Google 搜索發(fā)現(xiàn)了這個(gè) Nets.TutsPlus 網(wǎng)站在其中我可以使用 JavaScript 示例代碼...但我需要知道如何在 PHP 中實(shí)現(xiàn)服務(wù)器端,而不是示例中的 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 是否相關(guān)?PHP 本身是否支持 Web Sockets?我想 PHP 實(shí)現(xiàn)的正確方向會(huì)有所幫助.
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.
實(shí)際上本教程有一個(gè)指向 phpwebsockets 的鏈接已損壞...這是應(yīng)該使用的庫嗎?
Actually the tutorial has a broken link to phpwebsockets...is this the library one should use?
Websockets.org 有一個(gè)測(cè)試應(yīng)用程序,但沒有提到 PHP.
Websockets.org has a test application, but no mention of PHP.
推薦答案
就本地可用的標(biāo)準(zhǔn) PHP WebSocket 對(duì)象而言,沒有本地支持.
There isn't native support in terms of there being a standard PHP WebSocket object natively available.
您需要使用圖書館.
接下來要考慮的是 WebSocket 服務(wù)器的運(yùn)行方式.通常 PHP 在 Apache、Nginx(通過 FastCGI)或 Microsoft IIS(通過 Fast CGI)上運(yùn)行.對(duì)于 Apache 和 IIS,這可能是一個(gè)問題,因?yàn)樗鼘?shí)際上并沒有考慮到 WebSockets 等持久連接的構(gòu)建.我不確定 Nginx.這就是為什么大多數(shù) PHP WebSocket 庫將構(gòu)建為獨(dú)立庫以作為自己的進(jìn)程運(yùn)行.
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 現(xiàn)已在 Windows 8 中發(fā)布
另見:Ajax推送系統(tǒng)
這篇關(guān)于對(duì) Web 套接字的原生 PHP 支持是否可用?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!