当客户端使用TCP连接到服务器时,会为TCP流创建一个新的套接字。
When a client connects to a server using TCP, a new socket is created for the TCP stream. Does the connection remain on the same port the connection was made or does it get changed to some other port?
推荐答案新套接字是否已连接到相同的连接端口?是引入的应用程序级概念,因为每个建立的连接需要一个唯一的文件描述符(也不同于侦听文件描述符),映射到TCP会话但不一样。会话本身由源和目的地地址和端口的组合来标识。源(客户端)端口通常是随机选择的,而目标(服务器)端口是侦听端口。没有分配其他端口。
The new socket is an application-level concept introduced because each established connection needs a unique file descriptor (also distinct from the listening file descriptor), which maps to, but isn't the same as, a TCP session. The session itself is identified by the combination of source and destination address and port. The source (client) port is usually chosen at random, while the destination (server) port is the listen port. No additional port is allocated.
更多推荐
服务器接受TCP连接时端口是否改变?
发布评论