Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi guys, I'm starting with VB.NET 2003 (as requested per job's 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!

  • 2 months later...
Posted
Although not the most elegant solution, you can just catch the SoapException that gets thrown when the port is already in use:
TcpListener server;

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...