Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to find 80 port is in use or not

how to find 80 port is in use or not

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorial
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    venkatesh52867
    wrote on last edited by
    #1

    hi how to find 80 port is in use or not with c++ code or mfc

    G _ 2 Replies Last reply
    0
    • V venkatesh52867

      hi how to find 80 port is in use or not with c++ code or mfc

      G Offline
      G Offline
      Garth J Lancaster
      wrote on last edited by
      #2

      the only way I know is to attempt to connect to the port - if that fails, the most likely reason is, is that the port is in use There's some code here that may be useful - you should be able to rework it to suit your needs http://www.intelliproject.net/articles/showArticle/index/check_tcp_udp_port[^]

      D 1 Reply Last reply
      0
      • G Garth J Lancaster

        the only way I know is to attempt to connect to the port - if that fails, the most likely reason is, is that the port is in use There's some code here that may be useful - you should be able to rework it to suit your needs http://www.intelliproject.net/articles/showArticle/index/check_tcp_udp_port[^]

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Garth J Lancaster wrote:

        the only way I know is to attempt to connect to the port - if that fails, the most likely reason is, is that the port is in use

        In use or unavailable? I ask because can't there be more than one connection to a port?

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

        G 1 Reply Last reply
        0
        • D David Crow

          Garth J Lancaster wrote:

          the only way I know is to attempt to connect to the port - if that fails, the most likely reason is, is that the port is in use

          In use or unavailable? I ask because can't there be more than one connection to a port?

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

          G Offline
          G Offline
          Garth J Lancaster
          wrote on last edited by
          #4

          well your use of 'unavailable' hit the nail on the head for the case I was thinking of - 'client had disconnected, but port was in timeout-wait' - ergo, not technically in use .. this may be particular to the scenario/implementation I see if happen in (a lot, unfortunately) as to more than one connection to a port, I'd have to go back to my W Richard Stevens to check - I know what we 'see' happening in a lot of cases - eg multiple connectiins to tcp://w.x.y.z:80 may not necessarily be the case - the initial connection is accepted on that port, but then 'spun off' to be handled as a seperate conversation, leaving port 80 free Is that what you were thinking ?

          1 Reply Last reply
          0
          • V venkatesh52867

            hi how to find 80 port is in use or not with c++ code or mfc

            _ Offline
            _ Offline
            _Superman_
            wrote on last edited by
            #5

            I'm not sure if this is relevant to you, but you can call bind[^] on the ip address and port, check if it fails and see if the error is WSAEADDRINUSE.

            «_Superman_»  _I love work. It gives me something to do between weekends.

            _Microsoft MVP (Visual C++) (October 2009 - September 2013)

            Polymorphism in C

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups