Reputation: 5892
My app opens random ports from time to time and uses them. I've seen a problem where over a long period of time, there is a resource leak.
Is there a way to programatically get a list of open TCP and UDP ports that my current app is using? I need this information for the currently running app, not for external apps.
Any ideas of how to get a list of open ports without having to just check each port one by one to see if they're opened?
Upvotes: 0
Views: 74
Reputation: 5124
You can use this:
https://code.msdn.microsoft.com/windowsdesktop/C-Sample-to-list-all-the-4817b58f
and take the ports associated with your PID.
Upvotes: 2