socket 为什么叫套接字?

socket 英文原意为 插座
操作系统中,通常会为应用程序提供一组应用程序接口(API),称为套接字接口(英语:socket API)。应用程序可以通过套接字接口,来使用网上套接字,以进行数据交换。
最早的套接字接口来自于4.2 BSD,因此现代常见的套接字接口大多源自Berkeley套接字(Berkeley sockets)标准。在套接字接口中,以IP地址通信端口组成套接字地址(socket address)。远程的套接字地址,以及本地的套接字地址完成连线后,再加上使用的协议(protocol),这个五元组(five-element tuple),作为套接字对(socket pairs),之后就可以彼此交换数据。例如,在同一台计算机上,TCP协议与UDP协议可以同时使用相同的port而互不干扰。 操作系统根据套接字地址,可以决定应该将数据送达特定的进程线程。这就像是电话系统中,以电话号码加上分机号码,来决定通话对象一般。
(client_ip, client_port, server_ip, server_port, prootocol)
source(server),destination(client)

套接:
套接管可以理解为“将两个管子的接口包裹住用以将两个管口连接在一起套筒。

字(Word):
字在计算机中有专有意义
https://en.wikipedia.org/wiki/Word_(computer_architecture))
In computing, a word is the natural unit of data used by a particular processor design. A word is a fixed-sized piece of data) handled as a unit by the instruction set or the hardware of the processor. The number of bits in a word (the word size, word width, or word length) is an important characteristic of any specific processor design or computer architecture.

每个字节8位,在32位计算机的情况下,4个字节刚好可以用一个字(word)来表示。
image.png
一个ip地址也是32位,也就是一个字。(IPV4,IPV6是128位)

所以 socket 可以理解为 连接两个计算机的管子,为了更像计算机术语,所以叫套接字。