Home All Groups Group Topic Archive Search About

Who is using a given port?

Author
5 Jul 2006 12:06 PM
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

Author
5 Jul 2006 5:46 PM
Mike Lowery
"netstat -anb" displays this information, but I'm not sure how one would do it
programmatically.

<tommaso.gasta***@uniroma1.it> wrote in message
Show quoteHide quote
news:1152101181.019592.305380@a14g2000cwb.googlegroups.com...
> 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
>
Author
6 Jul 2006 12:02 PM
tommaso.gastaldi
Good to know that, Mike.

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

Mike Lowery ha scritto:

Show quoteHide quote
> "netstat -anb" displays this information, but I'm not sure how one would do it
> programmatically.
>
> <tommaso.gasta***@uniroma1.it> wrote in message
> news:1152101181.019592.305380@a14g2000cwb.googlegroups.com...
> > 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
> >
Author
6 Jul 2006 6:59 PM
Mike Lowery
Probably not part of the Framework, but obviously part of the Win32 API.

<tommaso.gasta***@uniroma1.it> wrote in message
Show quoteHide quote
news:1152187339.880080.98440@m73g2000cwd.googlegroups.com...
> Good to know that, Mike.
>
> It would be nice to be able to do it within vb.net.
>
> Mike Lowery ha scritto:
>
>> "netstat -anb" displays this information, but I'm not sure how one would do
>> it
>> programmatically.
>>
>> <tommaso.gasta***@uniroma1.it> wrote in message
>> news:1152101181.019592.305380@a14g2000cwb.googlegroups.com...
>> > 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
>> >
>