Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

I want to get the unused ports in my system for my CSOcket server because I am running server at the time of application start up. I don't like my application crashing at start up that's why I need unused port for my server. I don't how to get the list of ports which is unused.

Thanks in advance
ganesh_IT
Posted
Updated 24-Jan-11 1:38am
v2
Comments
CPallini 24-Jan-11 8:10am    
Anyway your application shouldn't crash just because the port is busy.

Can't you just bind to port 0 which should give you an available port?

http://msdn.microsoft.com/en-us/library/xz019029%28v=vs.80%29.aspx[^]

nSocketPort
A well-known port to be used with the socket, or 0 if you want Windows Sockets to select a port.
 
Share this answer
 
You can use program tcpview to look at programs runing on port and using sockets.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900