And the difference between HTTP and WebSocket principle

  https://www.cnblogs.com/goeasycloud/p/9355164.html

 

Today, speaking about agreements with other differences and similarities, students can give you a more in-depth to understand and use a variety of protocols.

1 What is the WebSocket ?

  WebSocket from meet-based Web-growing demand for real-time communication came into being to solve the client to initiate multiple Http request to the server resources browser must be in the polling question after a long period to achieve in the multiplex, it is full duplex, bidirectional, single-socket connection, the server and the client may transmit the information simultaneously WebSocket protocol.

 

2 WebSocket and Http similarities and differences

With: 1 built on top of TCP, by transmitting data TCP protocol.

2 are reliable transport protocol.

3 is an application layer protocol.

Different: 1 is the WebSocket HTML5 in the protocol, supports persistent connections, HTTP does not support persistent connections

2 HTTP protocol is one-way, can only be initiated by the client, the server can not take the initiative to push information to the client.

 

3 WebSocket和Socket

  Socket itself is not an agreement, it works in the OSI model is the session layer, is a socket, TCP / IP network API , in order to facilitate a more direct use of the underlying agreement exists an abstraction layer. Socket is actually a facade pattern, it is the complexity of TCP / IP protocol suite hidden Socket behind the interface, the user, a set of simple interface is all, let Socket to organize data in order to comply with the specified protocol.

  And WebSocket is a typical application layer protocol.

 

4 WebSocket  HTTP和TCP/IP

 WebSocket and HTTP, are built on top of TCP, by TCP to transfer data. A later article I will use an example to show the sub-codes.

 

. 5 Socket and TCP / IP   Socket is encapsulation of TCP / IP protocol, like creating Socket connection, can be used to specify the transport layer protocol, Socket may support different transport protocols ( TCP or the UDP ), when using the TCP protocol connection when the Socket connection is a TCP connection. 

  Having said that, I want to understand the WebSocket with the Socket, TCP, relationship HTTP helpful if you need to use them at work when WebSocket can not solve the problem, suggest that you can use at some of the tripartite WebSocket , financial cloud, Aurora, GoEasy, etc., I am here to give you a simple push of a tripartite free the WebSocket, GoEasy. Very mature product, it is recommended because the code is simple, stable operation. Website is www.goeasy.io , you can take a look yourself. Next article I will use the code to illustrate the article did not specify where.

Guess you like

Origin www.cnblogs.com/mengbin0546/p/12508848.html