The difference between a socket connection and an HTTP connection

Source: Internet
Author: User

 

To put it simply, the Web page you are viewing (the URL begins with http://) is transmitted to your browser by the HTTPS protocol, and HTTP is based on the socket, which is a set of interfaces to complete the TCP, UDP protocol.

HTTP protocol: Simple Object Access Protocol, corresponding to the application layer, the HTTP protocol is based on the TCP connection.

TCP protocol: Corresponds to the transport layer

IP protocol: Corresponds to the network layer

TCP/IP is a Transport layer protocol that mainly addresses how data is transmitted over the network: HTTP is an application-layer protocol that mainly addresses how data is packaged.

Socket is the TCP/IP protocol encapsulation, the socket itself is not a protocol, but a call interface (API), through the socket, we can use the TCP/IP protocol.

HTTP connection: The HTTP connection is called a short connection, that is, the client sends a request to the server, and the server-side response is disconnected.

Socket connection: Socket is the so-called long connection, in theory, the client and the server side once established connection will not be active, but due to various environmental factors may cause disconnection, such as: Server side or client host down, network failure, Or there is no data transfer between the two for a long time, the network firewall may disconnect the connection to free up network resources, so when there is no data transfer in a socket connection, heartbeat messages are sent to maintain the connection, and the heartbeat message is the developer's own definition.

The difference between a socket connection and an HTTP connection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.