Who is using a given port?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tommaso.gastaldi@uniroma1.it

    #1

    Who is using a given port?

    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.IPAd dress = IPAddress.Parse ("127.0.0.1" )
    Dim TcpListener As New TcpListener(Loc alIP, Port)
    TcpListener.Sta rt() '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

  • Mike Lowery

    #2
    Re: Who is using a given port?

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

    <tommaso.gastal di@uniroma1.itw rote in message
    news:1152101181 .019592.305380@ a14g2000cwb.goo glegroups.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.IPAd dress = IPAddress.Parse ("127.0.0.1" )
    Dim TcpListener As New TcpListener(Loc alIP, Port)
    TcpListener.Sta rt() '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
    >

    Comment

    • tommaso.gastaldi@uniroma1.it

      #3
      Re: Who is using a given port?

      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
      programmaticall y.
      >
      <tommaso.gastal di@uniroma1.itw rote in message
      news:1152101181 .019592.305380@ a14g2000cwb.goo glegroups.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.IPAd dress = IPAddress.Parse ("127.0.0.1" )
      Dim TcpListener As New TcpListener(Loc alIP, Port)
      TcpListener.Sta rt() '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

      Comment

      • Mike Lowery

        #4
        Re: Who is using a given port?

        Probably not part of the Framework, but obviously part of the Win32 API.

        <tommaso.gastal di@uniroma1.itw rote in message
        news:1152187339 .880080.98440@m 73g2000cwd.goog legroups.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
        >programmatical ly.
        >>
        ><tommaso.gasta ldi@uniroma1.it wrote in message
        >news:115210118 1.019592.305380 @a14g2000cwb.go oglegroups.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.IPAd dress = IPAddress.Parse ("127.0.0.1" )
        Dim TcpListener As New TcpListener(Loc alIP, Port)
        TcpListener.Sta rt() '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
        >
        >

        Comment

        Working...