Who is using a given port?

  • Thread starter tommaso.gastaldi
  • Start date
T

tommaso.gastaldi

Hi friend,

I am playing with Listeners. When one define a new TcpListener and
starts listening it may happen that there is some other program using
that channel.
For instance, on my pc DB2 is using port 50000.

Const Port As Integer = 50000
Dim LocalIP As System.Net.IPAddress = IPAddress.Parse("127.0.0.1")
Dim TcpListener As New TcpListener(LocalIP, Port)
TcpListener.Start() 'would rise exception

Does anybody have any hint on how can I get the information (at least
the name) of a process that is already using a port for its own
purposes? I would like to be able to inform the User that a port is
being used and, especially, by who.

Thanks,

-Tom
 
M

Mike Lowery

"netstat -anb" displays this information, but I'm not sure how one would do it
programmatically.
 
T

tommaso.gastaldi

Good to know that, Mike.

It would be nice to be able to do it within vb.net.

Mike Lowery ha scritto:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top