Sockets originate from UNIX, and one of Unix/linux's basic philosophies is that "everything is a file" and can be manipulated with "opening open, read-write write/read-close" mode. My understanding is that the socket is an implementation of the pattern, the socket is a special kind of file, some of the socket function is the operation of it (read/write Io, open, close),
When we transmit data, we can only use the (Transport Layer) TCP/IP protocol, but then, if there is no application layer, it will not be able to identify the data content, if you want to make the transferred data meaningful, you must use the Application layer protocol, the application layer protocol, such as HTTP, FTP, Telnet, etc., also You can define the application layer protocol yourself, the Web uses the HTTP protocol to do the application layer protocol to encapsulate HTTP text information, and then use TCP/IP as the Transport layer protocol to send it to the network.
(1) socket is a TCCP and UDP programming interface, you can use it to establish a TCP connection, and so on, and TCP and UDP protocol protocol belongs to the Transport layer, and HTTP is an application layer protocol, it is actually built on the TCCP protocol. HTTP is a sedan that provides a specific form of encapsulation or display data, and the socket itself is the engine that provides the ability to communicate over the network.
(2) socket is the TCP/IP protocol encapsulation, the socket itself is not a protocol, but the call interface (API), through the socket, we can use the TCP/IP protocol abstraction, thus forming some of the most basic function interfaces we know.
What is a socket??