Alibaba cloud Q & A 2022-02-13 08:23:10 阅读数:62
Linux Kernel total 65535 A port number is available , In other words, a machine can only be opened at most without considering multiple network cards 65535 individual TCP port . But we often see millions of single machines TCP Connect , How can this be done ？
because TCP It's a quadruple （Client End IP + Client End Port + Server End IP + Server End Port） As TCP The unique identity of the connection . If you do TCP Of Server End , No matter how many Client The end is connected , Local users only need to use the same port number . And if as TCP Of Client End , When the opposite end of the connection is the same IP + Port, It's true that each connection takes up a local port , But if the opposite end of the connection is not the same IP + Port, In fact, local ports can be reused , So actually Linux There are a lot of ports available in （ As long as the quadruple doesn't repeat ）.
source ：《Java Developer interview treasure book 》, link ：https://developer.aliyun.com/topic/download?id=7899
copyright：author[Alibaba cloud Q & A]，Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130823089604.html