Who is using a given port?

  • Thread starter Thread starter tommaso.gastaldi
  • Start date 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
 
"netstat -anb" displays this information, but I'm not sure how one would do it
programmatically.
 
Good to know that, Mike.

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

Mike Lowery ha scritto:
 
Back
Top