为什么我们需要网络套接字? [英] Why do we need web-sockets?

查看:25
本文介绍了为什么我们需要网络套接字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这更像是一个 n00b 问题,但我从来没有真正知道答案.

This is more of a n00b question, but I've never really known the answer.

那为什么我们需要 websockets 协议?

so why do we need the websockets protocol?

以及,与彗星式/长轮询/挂起 GET 式 HTTP 使用相比,有哪些优势?

and, what are the advantages over comet-style/long poll/hanging GET-style use of HTTP?

推荐答案

Comet 和 Ajax 都可以提供终端用户体验,提供类似桌面的功能和低用户感知延迟,只有 Web Sockets 兑现了提供的承诺一种本地方式,以可忽略的延迟准确有效地将事件传入和传出浏览器.

Comet and Ajax can both deliver end-user experiences that provide desktop-like functionality and low user-perceived latency, only Web Sockets lives up to the promise of providing a native means to accurately and efficiently stream events to and from the browser with negligible latency.

通过轮询,它会发出不必要的请求,因此,在低消息速率的情况下,许多连接被不必要地打开和关闭.(与轮询一样,它会定期发送 HTTP 请求并立即收到响应.)

With polling it makes unnecessary requests and, as a result, many connections are opened and closed needlessly in low-message-rate situations.(as with polling it sends HTTP requests at regular intervals and immediately receives a response.)

Web Sockets 消除了开销并显着降低了复杂性.

Web Sockets remove the overhead and dramatically reduce complexity.

这篇关于为什么我们需要网络套接字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆