How to find the number of used ephemeral ports?

I have a situation where I encounter ephemeral exhaustion of the port, which leads to exceptions. I would like to disconnect connections to avoid this. Is there a way to determine the number of ephemeral ports used?

Thanks Erick

+3
source share
2 answers

The only way to get rid of ephemeral TCP ports is if you are a client and you have opened almost 64k outbound connections and have not closed them in the last two minutes.

This sometimes happens in test scripts, but this is not a real case, so it is not of particular interest.

The symptom of this is a communication error while connecting. If you do not receive communication errors, you do not have this problem.

+1
source

To get a list of open connections, you can use the netstat command. Contrary to popular belief (from other answers) the number of Ephemeral ports is limited (4000 in Windows 2003, about 16000 in later versions, 16000 on most Linux). Also note that it takes 4 minutes to free a port so that it is not in use, so this can be a problem.

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

+1
source

All Articles