When transmitting data, we can only use the (Transport Layer) TCP/IP protocol. However, without the application layer, we cannot identify the data content. If we want to make the transmitted data meaningful, you must use the application layer protocol. There are many application layer protocols, such as HTTP, FTP, and telnet. You can also define the application layer protocol by yourself. The Web uses HTTP as the application layer protocol to encapsulate HTTP text information, and then uses TCP/IP as the transport layer protocol to send it to the network.
1) socket is an interface programmed for TCP and UDP. You can use it to establish TCP connections. TCP and UDP protocols belong to the transport layer.
HTTP is an application layer protocol, which is also based on the TCP protocol.
(HTTP is a car that provides a specific form of encapsulation or display data; socket is an engine that provides network communication capabilities .)
2) socket is the encapsulation of TCP/IP protocol. socket itself is not a protocol, but an interface (API) called. Through socket, we can use TCP/IP protocol. The emergence of socket only makes it easier for programmers to use the TCP/IP protocol stack. It is an abstraction of the TCP/IP protocol, thus forming some of the most basic function interfaces we know.
Ing between Socket API and TCP State _ three-way handshake (Listen, accept, connect) _ four-way handshake close and TCP Delay confirmation (call the setsockopt function once and set tcp_quickack) _ be careful with the "package seek" issue of persistent connection APIs