给定的目标端口可以与多个TCP连接关联吗?
在进行了一些搜索之后,我了解了几点,
- 我们无法为TCP复用一个端口。
- 如果两个连接使用相同的协议并具有相同的目标端口,则它们必须具有相同的连接。
- 我对某些网站的说法如何在同一端口上只能在同一端口上听一个应用程序,而其他人则说多个侦听TCP插座都可以共存,我很困惑不同的本地IP地址。
阅读上述内容使我比以往任何时候都更加困惑。目标端口可以与多个TCP连接关联吗?
After doing some search for this, I got to know a few points
- We cannot multiplex a port for TCP.
- If two connections use the same protocol and have the same destination ports, they must have the same connection.
- I am quite confused about how some sites say that TCP can only have one application listening on the same port at one time while others say multiple listening TCP sockets, all bound to the same port, can co-exist, provided they are all bound to different local IP addresses.
Reading the above stuff has left me more confused than ever. Can a destination port be associated with more than one TCP connection?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是错误的。您 can 只要它们是唯一的连接,在同一端口上运行多个TCP连接。并且在同一过程中编写在多个TCP插座上多倍I/O的代码并不难。
这是错误的。 TCP连接是通过协议 +本地IP/port +和远程IP/端口的组合唯一标识的。
如果使用不同的源IP/端口来连接,则使用相同协议和相同目标IP/端口的两个连接仍然是唯一的。例如,如果在同一台计算机上运行的多个客户端使用其他本地端口要连接,则可以连接到同一服务器。通常情况下,由于大多数客户使用由OS选择的随机可用本地端口进行出站连接。
同样,如果连接到其他目标IP/端口,使用相同协议和相同源IP/端口的两个连接仍然是唯一的。例如,在同一台计算机上运行的多个客户端可以使用相同的本地IP/端口连接到不同的服务器。
这是正确的,但是只有所有听众都试图同时使用相同的本地IP/端口。上面只允许1个听众。
这是正确的。
是的。即使该端口上只有1个侦听器,它接受的每个连接都将在服务器端使用相同的本地端口,但是与客户端端不同的源IP/端口。这允许来自不同远程计算机的多个客户端同时连接到同一服务器。
This is wrong. You can run multiple TCP connections on the same port, as long as they are unique connections. And it is not very difficult to write code that multiplexes I/O on multiple TCP sockets within the same process.
This is wrong. A TCP connection is uniquely identified by a combination of protocol + local IP/port + and remote IP/port.
Two connections that use the same protocol and same destination IP/port are still unique if they use different source IP/port to connect from. For instance, multiple clients running on the same machine can connect to the same server if they use a different local port to connect from. Which is typically the case, as most clients use a random available local port, selected by the OS, for the outbound connection.
Likewise, two connections that use the same protocol and the same source IP/port are still unique if they connect to different destination IP/port. For instance, multiple clients running on the same machine can use the same local IP/port to connect from if they connect to different servers.
This is correct, but only if all of the listeners are trying to use the same local IP/port at the same time. Only 1 listener is allowed on it.
This is correct.
Yes. Even if there is only 1 listener on that port, every connection it accepts will be using that same local port on the server side, but a different source IP/port from the client side. This allows multiple clients from different remote machines to connect to the same server at the same time.