/build/static/layout/Breadcrumb_cap_w.png

Get a unused port number

Hi every one.. m using .net frame work.. can ny one tell me that is there ny method to find out an unused port number in the system...
actully i need to select a port number which is free so that my sever socket can listen on that..

0 Comments   [ + ] Show comments

Answers (2)

Posted by: AngelD 17 years ago
Red Belt
0
Don't have a general solution for you but the command "netstat" will show running services and connected ports. You can also have a look at the services file located under C:\WINDOWS\system32\drivers\etc.
Posted by: aogilmor 17 years ago
9th Degree Black Belt
0
Hi, it looks like there is a method to manipulate ports in .NET.
http://msdn2.microsoft.com/en-us/library/system.servicemodel.netpeertcpbinding.port.aspx
There should be a way to enumerate used and free ports with this method. Have a look at the newsgroups.

Hope this helps.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ