In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you what the role of WebSocket, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!
Before the advent of Websocket, we can only use longpoll and ajax polling to maintain real-time communication with the server. Their principle is to let the browser send a request every few seconds, asking the server if there is any new information. All are through the continuous establishment of HTTP connections, and then wait for the server to process, which corresponds to the server is very expensive. Under this premise, Websocket appears, which well solves the passive type of http protocol, so that the server can actively push information to the client.
What is Websocket?
WebSocket is a new protocol under html5, which is used to solve the real-time communication between client and server. Its essence is to first shake hands through the HTTP/HTTPS protocol and then create a TCP connection for exchanging data, and then the server and the client communicate in real time through this TCP connection, which can better save server resources and bandwidth and achieve the purpose of real-time communication. But the biggest difference between it and HTTP is:
WebSocket is a two-way communication protocol. After establishing a connection, both the WebSocket server and the client can actively send or receive data to each other, just like Socket
Like TCP, WebSocket needs to establish a connection before it can communicate with each other.
WebSocket only needs to go through a HTTP request to transmit a steady stream of information. (in programming, this design is called a callback, that is, let me know when you have information, instead of asking you every time I come to you foolishly.) such a protocol solves the situation where there is a delay in synchronization and consumes a lot of resources.
Application scenarios of Websocket
Social chat, multiplayer games, on-screen comments, collaborative editing, real-time quotes from stock funds, live sports updates, video conferencing / chat, location-based applications, online education, smart home, etc., all require high real-time scenarios.
Html5WebSocketsAPI
Browser support detection
Functiondemo () {
If (window.WebSocket) {
/ / support
} else {
/ / not supported
}
}
These are all the contents of this article "what is the purpose of WebSocket?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.