javascript Node.js/Socket.io 中对旧浏览器的 Web Socket 支持
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19903646/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Web Socket support in Node.js/Socket.io for older browser
提问by Chris_vr
I have created a Web Socket server using c++.As we know that HTML 5 support Web Socket and we have standard Web Socket Java Script Api to communicate with web socket server.I am able to connect to web Socket server using Web Socket Api. Since Web Socket Api is supported in Only new browser.
我已经使用 c++ 创建了一个 Web Socket 服务器。我们知道 HTML 5 支持 Web Socket,并且我们有标准的 Web Socket Java Script Api 来与 Web Socket 服务器通信。我能够使用 Web Socket Api 连接到 Web Socket 服务器。由于仅在新浏览器中支持 Web Socket Api。
IE version 10
Chrome version 16
Firefox version 6
Safari version 6.0
Opera version 12.10
I need to provide supportfor following browser version as well.
Web Socket Api Supported browser
我还需要为以下浏览器版本提供支持。
Web Socket Api 支持的浏览器
IE version 7
Chrome version 14
Firefox version 4
Safari version 5.1
I heard about node.js and socket.io. both are supported on
我听说过 node.js 和 socket.io。两者都支持
Web Socket Api not Supported Browser
Internet Explorer 5.5+
Safari 3+
Google Chrome 4+
Firefox 3+
Opera 10.61+
不支持 Web Socket Api 浏览器
Internet Explorer 5.5+ Safari 3+ Google Chrome 4+ Firefox 3+ Opera 10.61+
I wanted to write java script client to connect to Web Sokcet server using Node.js/Socket.io
我想编写 java 脚本客户端来使用 Node.js/Socket.io 连接到 Web Sokcet 服务器
Does Node.js/Socket.io allow me to connect in older browser ?
Node.js/Socket.io 是否允许我在旧浏览器中连接?
回答by T.J. Crowder
You can support those browsers with Socket.io, yes, but not specifically with web sockets (as many of those browsers versions don't have web sockets).
您可以使用 Socket.io 支持这些浏览器,是的,但不是专门使用网络套接字(因为许多浏览器版本没有网络套接字)。
As of November 2013, Socket.io's list of supported browsers was:
截至 2013 年 11 月,Socket.io 支持的浏览器列表为:
Desktop:
桌面:
- Internet Explorer 5.5+
- Safari 3+
- Google Chrome 4+
- Firefox 3+
- Opera 10.61+
- Internet Explorer 5.5+
- 野生动物园 3+
- 谷歌浏览器 4+
- 火狐 3+
- 歌剧 10.61+
Mobile:
移动的:
- iPhone Safari
- iPad Safari
- Android WebKit
- WebOs WebKit
- iPhone Safari
- iPad Safari
- 安卓网页套件
- WebOs WebKit
They achieve this level of support by using a variety of transports, depending on what the browser is capable of (again, from November 2013):
他们通过使用各种传输实现这种级别的支持,具体取决于浏览器的功能(同样,从 2013 年 11 月开始):
- WebSocket
- Adobe? Flash? Socket
- AJAX long polling
- AJAX multipart streaming
- Forever Iframe
- JSONP Polling
- 网络套接字
- 土坯?闪光?插座
- AJAX 长轮询
- AJAX 多部分流
- 永远的 iframe
- JSONP 轮询
Since then, Socket.io has been split upinto (at least) Socket.io and Engine.io where the latter provides the transports. And it seems like Engine.io's list of transports has dramatically reduced:
从那时起,Socket.io被拆分为(至少)Socket.io 和 Engine.io,后者提供传输。似乎 Engine.io 的传输列表已大大减少:
polling: XHR / JSONP polling transportwebsocket: WebSocket transport
polling: XHR / JSONP 轮询传输websocket: WebSocket 传输
It seems to suggest there's still a way of doing Flash sockets as well.
这似乎表明还有一种方法可以实现 Flash 套接字。
Presumably this reflects the fact that websockets are almost universally supported in modern browsers.
据推测,这反映了现代浏览器几乎普遍支持 websockets的事实。

