TCP:两个不同的套接字可以共享一个端口吗? [英] TCP: can two different sockets share a port?

查看:395
本文介绍了TCP:两个不同的套接字可以共享一个端口吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个非常基本的问题,但这使我感到困惑.

This might be a very basic question but it confuses me.

两个不同的连接插座可以共享一个端口吗?我正在编写一个应该能够处理超过100k并发连接的应用程序服务器,并且我们知道系统上可用的端口数约为60k(16位).一个已连接的套接字被分配给一个新的(专用)端口,因此这意味着并发连接数受端口数的限制,除非多个套接字可以共享同一端口.问题是这样.

Can two different connected sockets share a port? I'm writing an application server that should be able to handle more than 100k concurrent connections, and we know that the number of ports available on a system is around 60k (16bit). A connected socket is assigned to a new (dedicated) port, so it means that the number of concurrent connections is limited by the number of ports, unless multiple sockets can share the same port. So the question.

感谢您的提前帮助!

推荐答案

服务器套接字在单个端口上侦听.该服务器上所有已建立的客户端连接都与该服务器的同一监听端口 关联.客户端和服务器端IP/端口对的组合唯一标识已建立的连接.同一服务器上的多个连接可以共享相同的服务器端 IP/端口对,只要它们与不同的客户端 IP/端口对和服务器将能够处理可用系统资源所允许的尽可能多的客户端.

A server socket listens on a single port. All established client connections on that server are associated with that same listening port on the server side of the connection. An established connection is uniquely identified by the combination of client-side and server-side IP/Port pairs. Multiple connections on the same server can share the same server-side IP/Port pair as long as they are associated with different client-side IP/Port pairs, and the server would be able to handle as many clients as available system resources allow it to.

客户端上,通常的做法是,新的出站连接使用随机的客户端端口,在这种情况下,可能会耗尽如果您在短时间内建立大量连接,则可用端口.

On the client-side, it is common practice for new outbound connections to use a random client-side port, in which case it is possible to run out of available ports if you make a lot of connections in a short amount of time.

这篇关于TCP:两个不同的套接字可以共享一个端口吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆