In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
How to carry out the comparative analysis of Socke, WS and WSS? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
Socket communication
Socket does not belong to the category of network protocols, but an abstract layer between the application layer and the transport layer. It abstracts the complex operations of the TCP/IP layer into several simple interface provisioning layer calls. Calling Socket makes it easier for programmers to use the TCP/IP protocol stack.
The Socket connection is a persistent connection, and theoretically, the client and server will not actively disconnect the connection once the connection is established. The Socket connection is in the form of request-response, and the server can actively push the message to the client.
WebSocket/WSS introduction
WebSocket (WS) is a new protocol of HTML5. It realizes full-duplex communication between browser and server, which can better save server resources and bandwidth and achieve real-time communication.
WebSocket is built on top of TCP and transmits data through TCP like HTTP, but the biggest difference between it and HTTP is:
WebSocket is a two-way communication protocol. After establishing a connection, both WebSocket server and Browser/Client Agent can actively send or receive data to each other, just like Socket.
WebSocket requires TCP-like clients and servers to shake hands before they can communicate with each other.
WSS (WebSocket Secure) is the encrypted version of WebSocket.
WS/WSS usage scenario
With the vigorous development of the Internet, various types of Web applications emerge in endlessly. Many applications require the server to have the ability to push in real time (such as live chat rooms). In the past, many websites used polling technology in order to achieve push technology. Polling is a browser in which the browser issues a HTTP request to the server at a specific time interval (such as every 1 second), and then the server returns the latest data to the client. This traditional mode brings obvious disadvantages, that is, browsers need to constantly make requests to the server, but HTTP requests may contain long headers, in which the really valid data may be only a small part, which will obviously waste a lot of bandwidth resources.
In this case, HTML5 defines the WebSocket protocol, which can better save server resources and bandwidth, and can communicate in more real time. WebSocket implements full-duplex (full-duplex) communication between the browser and the server, allowing the server to actively send information to the client.
The interaction process of the WebSocket protocol is shown in the following figure
WSS related API in Mini Program
WeChat Mini Programs supports the WSS protocol and provides the following API:
WebSocket
Wx.sendSocketMessage
Wx.onSocketOpen
Wx.onSocketMessage
Wx.onSocketError
Wx.onSocketClose
Wx.connectSocket
Wx.closeSocket
Alipay Mini Program supports the WSS protocol and provides the following API:
WebSocket
My.connectSocket
My.onSocketOpen
My.offSocketOpen
My.onSocketError
My.offSocketError
My.sendSocketMessage
My.onSocketMessage
My.offSocketMessage
My.closeSocket
My.onSocketClose
My.offSocketClose
Mini Program MQTT connects to IoT Internet of things platform
WeChat Mini Programs and Alipay Mini Program both support the WSS protocol, so we can use MQTT over Websocket to access the IoT Internet of things platform to achieve two-way communication.
This is the answer to the question on how to conduct the comparative analysis of Socke, WS and WSS. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
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.