什么是WebSocket? —初学者编码



什么是WebSocket? —初学者编码

http://colorcode.io/course/tech-in-90-seconds/?video=websockets

90秒内的技术-WebSockets

作者:约翰·保罗(John K. Paul)

WebSockets是另一种协议,类似于http,但是在浏览器内部却更多。您可能从未在浏览器的位置栏中看到过以WS开头的URL,但是在幕后,您喜欢的许多应用程序(例如Slack,Gmail和Twitter)都在使用Web套接字。

浏览器内部的典型HTTP请求响应周期类似于1.有人单击链接或在2.中键入url。向服务器发出http请求。3.服务器用一些数据响应浏览器。这需要一些东西,使某种系统能够很好地适用于各种各样的事情,例如阅读新闻或检查天气,但是如果您想在这个世界上获得更多实时信息,例如聊天,电子邮件或推特,我们必须打电话说“嘿,还有其他什么”,“嘿,还有其他什么?”所有的时间。

WebSockets的目的是允许与后端服务器的持久连接。就像电话一样,双方都无需挂断电话,如果在几秒钟或几分钟后收到新信息,则无需打新电话。如果服务器具有用于浏览器的数据,则仅发送该数据,而不必等待浏览器询问“其他任何内容”的时间。

使用该技术的开发人员可以创建一个后端和前端组合系统,该系统可以非常快速地对新数据做出响应,就像新数据流入浏览器一样,因此WebSockets是“实时” Web应用程序的基础。 。

29 comments
  1. You explain so complicated concepts so clearly! You should really consider making udemy courses or something. I would definitely buy them

  2. Wow man, in a world of super long drawn out videos – yours was perfect. You went straight to the point, no extraneous info – succinct and to the point. You just got a subscriber

  3. Help Please!!.. I recently learned node.js and now learning web sockets, to use socket.io (or anywebsocket)
    do we have to write a special server ?, so WebSocket can bind on to it?
    or we can just bind to the main hosting server (mine at hostgator), Because I m making this chatting website and planning to upload to a hosting site, where they traditionally provide you with server you just have to put you file on that server, so is it like I have to make server inside server or I get my WebSocket latch to that traditional server? I m so confused,
    am I missing something? I googled but can't seem to find anything, any
    help from you guys will be great, Please Explain! lastly sorry for my
    bad english.

Comments are closed.