Summary:
I was a little confused about these concepts. I checked some materials and summarized their differences. If any error occurs, take a picture ~~~
First look at the figure:
What is TCP/IP?
TCP/IP is a protocol group, which can be divided into three layers: network layer, transport layer and application layer.
The IP protocol, ICMP protocol, ARP protocol, RARP protocol, and BOOTP protocol are available at the network layer.
There are TCP and UDP protocols in the transport layer.
The application layer includes FTP, HTTP, telnet, SMTP, DNS, and other protocols.
SocketWhat is it?
SocketIs the application layer andTCP/IPThe intermediate software abstraction layer for protocol communication. A group of interfacesTCP/IPThe protocol family is hidden inSocketInterface.
So HTTP isTCP/IP application layer protocol.Socket is their software abstraction layer.
transient connection:
connection> data transmission> close connection
HTTP is stateless, each HTTP operation between the browser and the server establishes a connection, but the connection is interrupted when the task ends.
You can also say that a short connection means that the connection is closed immediately after the data is received after the socket connection is sent.
persistent connection:
connection> data transmission> keep connection> data transmission>... -> Close the connection.
persistent connection means that the connection is established after a socket connection is established, regardless of whether the connection is used or not, but the security is poor.
HTTP persistent connection:
HTTP can also establish persistent connections. Use connection: keep-alive, and HTTP 1.1 performs persistent connections by default. The biggest difference between http1.1 and http1.0 is that it supports persistent connections (appearance
similar to the specified keep-alive that can be displayed in the latest http1.0), but it is still stateless, or it cannot be trusted.