TCP/UTP port opened?

panchopp

New member
Joined
Mar 30, 2006
Messages
1
Hi guys, Im starting with VB.NET 2003 (as requested per jobs demand).
I have a requirement to look for a port and see if it is in use. Do you know of any commands to do that? Should I use some socket native function or what?
Thank you Very MUCH!
 
Although not the most elegant solution, you can just catch the SoapException that gets thrown when the port is already in use:
C#:
TcpListener server;

try
{
    server = new TcpListener(IPAddress.Any, 80);
    server.Start();
}
catch (SocketException ex)
{
    Console.WriteLine(ex);
}
 
Back
Top