How to find number of ephemeral ports in use?

本秂侑毒 提交于 2019-12-06 06:44:06

问题


I have a situation where I am running into ephemeral port exhaustion, which is then causing exceptions. I would like to throttle the connections to avoid this. Is there a way to detect the number of ephemeral ports in use?

Thanks, Erick


回答1:


To get list of open connection you may use netstat command. Contrary to popular believe (of other answers) number of Ephemeral ports is limited (4000 on Windows 2003, some 16000 on later versions, 16000 on most Linuxes). Note also that it take 4 minutes to release port once it become unused therefore it really can be an issue.

There is article on MSDN dealing with it: http://msdn.microsoft.com/en-us/library/aa560610(v=bts.20).aspx




回答2:


The only way you can run out of ephemeral TCP ports is if you are a client and you have opened nearly 64k outbound connections, and not closed them within the last two minutes.

This sometimes happens in testing scenarios, but it doesn't represent a real-world case so it is of no real interest.

The symptom of this is bind errors when connecting. If you aren't getting bind errors you don't have this problem.



来源:https://stackoverflow.com/questions/10237419/how-to-find-number-of-ephemeral-ports-in-use

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!