javascript engine.io 与 socket.io 有何不同?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9610951/
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
How is engine.io different from socket.io?
提问by rafidude
LearnBoost seems to have a new project called engine.iothat in theory seems to be similar to socket.io. 1) Under what scenarios would you use one versus the other? 2) For new projects that require HTML5 sockets based communication over node.js, should we use engine.io and NOT socket.io?
LearnBoost似乎有一个名为engine.io的新项目,理论上似乎类似于 socket.io。1) 在什么情况下你会使用一种和另一种?2) 对于需要基于 HTML5 套接字通过 node.js 进行通信的新项目,我们应该使用 engine.io 而不是 socket.io?
回答by nicholaides
From https://github.com/LearnBoost/engine.io
来自https://github.com/LearnBoost/engine.io
The main goal of Engine is ensuring the most reliable realtime communication. Unlike the previous socket.io core, it always establishes a long-polling connection first, then tries to upgrade to better transports that are "tested" on the side.
During the lifetime of the socket.io projects, we've found countless drawbacks to relying on HTML5 WebSocket or Flash Socket as the first connection mechanisms.
Both are clearly the right way of establishing a bidirectional communication, with HTML5 WebSocket being the way of the future. However, to answer most business needs, alternative traditional HTTP 1.1 mechanisms are just as good as delivering the same solution.
Engine 的主要目标是确保最可靠的实时通信。与之前的 socket.io 核心不同,它总是首先建立一个长轮询连接,然后尝试升级到更好的传输,这些传输是“经过测试”的。
在 socket.io 项目的生命周期中,我们发现依赖 HTML5 WebSocket 或 Flash Socket 作为第一个连接机制有无数的缺点。
两者显然都是建立双向通信的正确方式,HTML5 WebSocket 是未来的方式。然而,为了满足大多数业务需求,替代的传统 HTTP 1.1 机制与提供相同的解决方案一样好。
回答by Mark
engine.io is the new core for socket.io, so use socket.io unless you want some other API :-) According to the author of both modules, engine will be integrated into socket.io 1.0: http://groups.google.com/group/socket_io/browse_thread/thread/6e759a508b231b4
engine.io 是 socket.io 的新核心,所以使用 socket.io 除非你想要一些其他的 API :-) 根据两个模块的作者,引擎将被集成到 socket.io 1.0: http://groups。 google.com/group/socket_io/browse_thread/thread/6e759a508b231b4
"What's next
“下一步是什么
1.0 is right around the corner, which features our next-generation realtime core, Engine.IO. The 0.9 branch will only receive maintenance updates to ensure maximum stability. "
1.0 即将推出,它具有我们的下一代实时核心 Engine.IO。0.9 分支将只接收维护更新以确保最大的稳定性。”