In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail what are the differences between Socket Socket.io Websocket HTTP. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Differences between Socket Socket.io Websocket HTTP
Socket is an abstract interface for the transport layer (TCP / UDP) provided by the operating system, and it is a programming concept, while Websocket and Socket.io are written Internet protocols like HTTP. In addition, both Websocket and HTTP transmit data based on TCP, and Socket.io can be seen as another encapsulation of Websocket and HTTP.
HTTP is based on request-response, that is, communication can only be initiated by the client, the server can respond, stateless, no connection.
Stateless: only one request is processed for each connection, and the connection is disconnected after the request ends.
Connectionless: there is no memory for transactions, and the server does not know what the client state is.
In the past, the means to achieve instant messaging:
Polling: the client sends an Ajax request to the server regularly, and the server returns the response information and closes the connection immediately after receiving the request.
Long polling: the client sends an Ajax request to the server. After receiving the request, the server hold stops the connection, returns the response information and closes the connection until there is a new message, and the client sends a new request to the server after processing the response information.
Persistent connection: embed a hidden iframe in the page and set the src property of the hidden iframe to a request for a persistent connection, so that the server can continuously input data to the client.
Flash Socket: embed a Flash program JavaScript that uses the Socket class in the page to communicate with the Socket interface of the server by calling the Socket interface provided by the Flash program. JavaScript controls the display of the page after receiving the information sent by the server.
The emergence of Websocket is to solve the shortcomings of HTTP in instant messaging, HTTP is to achieve instant messaging through Polling there is a lot of resource overhead.
The HTTP protocol is used in the Webscoket handshake phase. After the connection is established, it has nothing to do with the HTTP protocol. After the Websocket connection is established, client and server can send and receive data at the same time, full-duplex communication.
Socket.io supports Websocket protocol and a variety of polling mechanisms. It implements a real-time, two-way, event-based communication mechanism and is naturally used to solve real-time communication problems. In addition, Socket.io can automatically choose the best way to realize network real-time application according to the browser's support for communication mechanism.
This is the end of this article on "what are the differences between Socket Socket.io Websocket HTTP?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.