This is my first question here so I hope I did it correctly.
I am using UDP packets to communicate through a server-client structure, where all clients communicate with the same server through UDP.
As I have understood it, for each client that sends a packet to the server, the server computer takes up one port for that client.
That means if ~65 000 clients connects to the same server computer it will not have more ports to allocate for connecting clients, which is bad.
When a port is allocated for the client, it will take 4 minutes for it be placed in the available pool again (according to https://learn.microsoft.com/en-us/windows/client-management/troubleshoot-tcpip-port-exhaust).
My problem is that I have not found a way to check the amount of available or used ports on the server computer.
For example, if I have a client machine with 2000 different connections (I know UDP is connectionless) against my server machine, the CMD command "netstat -ano" outputs all ports being used on the client machine (which is over 2000 of course).
However, on the server it does not show that many (less than 100) ports being used with the same command, which means that it does not show the ports allocated for the 2000 connections.
How can I fetch all used/unused ports on the server machine?
I realize that I can in my program get the ports being used and calculate how many ports are available in the pool, but that only takes care of the ports in my program, and not any other ports that might be used from other programs.