HTTP: Hypertext Transfer Protocol, first it is a protocol, and is based on the TCP/IP protocol on the basis of the application layer protocol. TCP/IP protocol is the Transport Layer protocol, which mainly solves how data is transmitted in the network, and HTTP is the application layer protocol, which mainly solves how to wrap the data. The HTTP protocol details the rules for communication between the browser and the server, and is the basis for the World Wide Web exchange of information. HTTP is based on the request-response form and is a short connection, and is a stateless protocol. For its stateless characteristics, in the actual application needs to have the form of the state, so generally through the Session/cookie technology to solve this problem.
Socket:socket is not a protocol category, but a calling interface (API), socket is the encapsulation of the TCP/IP protocol, by calling the socket, the TCP/IP protocol can be used. The socket connection is a long connection, in theory the client and server side will not actively disconnect this connection once the connection is established. The socket connection is a request-response form, and the server can proactively push messages to the client.
Http and Socket differences