Node.js/Socket.io 中对旧浏览器的 Web Socket 支持 [英] Web Socket support in Node.js/Socket.io for older browser
问题描述
我使用 c++ 创建了一个 Web Socket 服务器.我们知道 HTML 5 支持 Web Socket 并且我们有标准的 Web Socket Java Script Api 来与 Web Socket 服务器通信.我能够使用 Web Socket 连接到 Web Socket 服务器阿皮.由于仅在新浏览器中支持 Web Socket Api.
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.
IE version 10
Chrome version 16
Firefox version 6
Safari version 6.0
Opera version 12.10
我需要提供也支持以下浏览器版本.
Web Socket Api 支持的浏览器
I need to provide support for following browser version as well.
Web Socket Api Supported browser
IE version 7
Chrome version 14
Firefox version 4
Safari version 5.1
我听说过 node.js 和 socket.io.
I heard about node.js and socket.io. both are supported on
浏览器不支持 Web Socket Api
Internet Explorer 5.5+野生动物园 3+谷歌浏览器 4+火狐 3+歌剧 10.61+
Web Socket Api not Supported Browser
Internet Explorer 5.5+
Safari 3+
Google Chrome 4+
Firefox 3+
Opera 10.61+
我想编写java脚本客户端来使用Node.js/Socket.io连接到Web Sokcet服务器
I wanted to write java script client to connect to Web Sokcet server using Node.js/Socket.io
Node.js/Socket.io 允许我在旧浏览器中连接吗?
Does Node.js/Socket.io allow me to connect in older browser ?
推荐答案
您可以使用 Socket.io 支持那些浏览器,是的,但不是专门使用 Web 套接字(因为许多浏览器版本没有 Web 套接字).
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).
截至 2013 年 11 月,Socket.io 支持的浏览器列表为:
As of November 2013, Socket.io's list of supported browsers was:
桌面:
- Internet Explorer 5.5+
- Safari 3+
- 谷歌浏览器 4+
- 火狐 3+
- Opera 10.61+
移动:
- iPhone Safari
- iPad Safari
- Android WebKit
- WebOs WebKit
他们通过使用各种传输实现这种级别的支持,具体取决于浏览器的功能(同样,从 2013 年 11 月开始):
They achieve this level of support by using a variety of transports, depending on what the browser is capable of (again, from November 2013):
- WebSocket
- Adobe® Flash® 插座
- AJAX 长轮询
- AJAX 多部分流式传输
- 永远的 iframe
- JSONP 轮询
从那时起,Socket.io 被拆分为(至少)Socket.io 和 Engine.io,后者提供传输.看起来 Engine.io 的传输列表已经大大减少了:
Since then, Socket.io has been split up into (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:
polling
:XHR/JSONP 轮询传输websocket
:WebSocket 传输
polling
: XHR / JSONP polling transportwebsocket
: WebSocket transport
这似乎表明还有一种方法可以实现 Flash 套接字.
It seems to suggest there's still a way of doing Flash sockets as well.
大概这反映了这样一个事实:现代浏览器几乎普遍支持 websockets.
Presumably this reflects the fact that websockets are almost universally supported in modern browsers.
这篇关于Node.js/Socket.io 中对旧浏览器的 Web Socket 支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!