Giter VIP home page Giter VIP logo

Comments (2)

JohnGao818 avatar JohnGao818 commented on September 9, 2024

websocket协议
WebSocket 协议在2008年诞生,2011年成为国际标准。目前已基本被所有浏览器支持(过旧版本的浏览器会不支持)。
websocket协议允许客户端和服务端之间建立全双工通信,以便消息可以从任意一端发送到另一端,另外websocket只需建立一次长连接,连接建立后,消息可以随时在连接通道上进行传递。相比于轮询方式的大量请求效率大大提高。
优点:

  1. 只需建立一次连接,效率高,性能消耗低。
  2. 长连接,连接建立后,随时可以进行通信。
  3. 全双工,消息可以从客户端和服务端任意发起。
  4. 实时性好,减少了轮询间隔的时延。
  5. 不受同源策略限制,客户端可以与任意服务端申请建立连接(不一定是优点,需要考虑安全问题)

from keeplearning.

JohnGao818 avatar JohnGao818 commented on September 9, 2024

websocket使用案例

腾讯文档

image

图片

http
http通信过程
websocket
websocket通信过程

communication5

http轮询

communication4
websocket通信

from keeplearning.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.