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. network query

network query

Scheduled Pinned Locked Moved C / C++ / MFC
sysadmindatabase
8 Posts 3 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.
  • L Offline
    L Offline
    lucy 0
    wrote on last edited by
    #1

    I have a windows client application, which I want to use to communicate with a server application running on a different machine in the same LAN. To make it user friendly, instead of asking the user to input the host IP addres of the server to the client application, I want the client application to do a query in the LAN, and find out what the candidate server's IP address is, and all the user has to do is to confirm that that's the one to communicate with. I have no clue how I can get this done. Any hint would be greatly appreciated. Thanks a lot!

    R D 2 Replies Last reply
    0
    • L lucy 0

      I have a windows client application, which I want to use to communicate with a server application running on a different machine in the same LAN. To make it user friendly, instead of asking the user to input the host IP addres of the server to the client application, I want the client application to do a query in the LAN, and find out what the candidate server's IP address is, and all the user has to do is to confirm that that's the one to communicate with. I have no clue how I can get this done. Any hint would be greatly appreciated. Thanks a lot!

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      This[^] control will provide the source code to determine the list of visible servers on the LAN. /ravi

      This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

      L 1 Reply Last reply
      0
      • R Ravi Bhavnani

        This[^] control will provide the source code to determine the list of visible servers on the LAN. /ravi

        This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

        L Offline
        L Offline
        lucy 0
        wrote on last edited by
        #3

        ravi, Thank you for the link. but the server I am thinking of is not a generic server. It's just an application which runs on another computer, but serves as server in a client/server software. maybe I can use broadcast function, but is there any better way to implement it? for example, D-Link has a network storage adapter DNS-120. It has a built-in FTP server, so files can be accessed over the internet, when the disk is connected to this adapter. It has an application called "Easy Search", which is to easily locate DNS-120 units for configuration. What I want is similar to this "Easy Search", that is, click a button on this "Easy Search" application, it will return the IP addresses of my "DNS-120" units in the same LAN. English is not first language, so I hope I made myself a bit more clear now. Thank you for any hint!

        R 1 Reply Last reply
        0
        • L lucy 0

          ravi, Thank you for the link. but the server I am thinking of is not a generic server. It's just an application which runs on another computer, but serves as server in a client/server software. maybe I can use broadcast function, but is there any better way to implement it? for example, D-Link has a network storage adapter DNS-120. It has a built-in FTP server, so files can be accessed over the internet, when the disk is connected to this adapter. It has an application called "Easy Search", which is to easily locate DNS-120 units for configuration. What I want is similar to this "Easy Search", that is, click a button on this "Easy Search" application, it will return the IP addresses of my "DNS-120" units in the same LAN. English is not first language, so I hope I made myself a bit more clear now. Thank you for any hint!

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #4

          lucy wrote:

          application called "Easy Search",

          Discovery mechanisms such as this (and license severs) work by listening on a specific port. The server code needs to support a ping/ack request, in which case, all you need to do is ping the specific port on all visible servers in your LAN. The ones that respond are eligible candidates for your client. The ping/ack support can be made more useful if the server is smart enough to return additional information (eg: load, etc.) which would make it easier for your clients to select the appropriate one. Hope this helps! /ravi PS: Your English is fine. :)

          This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

          L 1 Reply Last reply
          0
          • R Ravi Bhavnani

            lucy wrote:

            application called "Easy Search",

            Discovery mechanisms such as this (and license severs) work by listening on a specific port. The server code needs to support a ping/ack request, in which case, all you need to do is ping the specific port on all visible servers in your LAN. The ones that respond are eligible candidates for your client. The ping/ack support can be made more useful if the server is smart enough to return additional information (eg: load, etc.) which would make it easier for your clients to select the appropriate one. Hope this helps! /ravi PS: Your English is fine. :)

            This is your brain on Celcius Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

            L Offline
            L Offline
            lucy 0
            wrote on last edited by
            #5

            thank you very much, ravi. now I understand the principle. Is there any tutorial material I can read to learn more? I'm pretty new to the network programming. what I have done is limited to very basic stuff, such as one-to-one send/recv applciation. thanks again!

            1 Reply Last reply
            0
            • L lucy 0

              I have a windows client application, which I want to use to communicate with a server application running on a different machine in the same LAN. To make it user friendly, instead of asking the user to input the host IP addres of the server to the client application, I want the client application to do a query in the LAN, and find out what the candidate server's IP address is, and all the user has to do is to confirm that that's the one to communicate with. I have no clue how I can get this done. Any hint would be greatly appreciated. Thanks a lot!

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

              lucy wrote:

              I want the client application to do a query in the LAN, and find out what the candidate server's IP address is...

              Use NetServerEnum() for this. Once you can successfully enumerate through all machines in your LAN, then you can go about "pinging" their ports.


              "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

              "Judge not by the eye but by the heart." - Native American Proverb

              L 1 Reply Last reply
              0
              • D David Crow

                lucy wrote:

                I want the client application to do a query in the LAN, and find out what the candidate server's IP address is...

                Use NetServerEnum() for this. Once you can successfully enumerate through all machines in your LAN, then you can go about "pinging" their ports.


                "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                "Judge not by the eye but by the heart." - Native American Proverb

                L Offline
                L Offline
                lucy 0
                wrote on last edited by
                #7

                thank you, this is very helpful. I then found this article: http://www.codeproject.com/internet/ipaddress.asp[^] now I'm on my way to the solution. Thanks again!

                D 1 Reply Last reply
                0
                • L lucy 0

                  thank you, this is very helpful. I then found this article: http://www.codeproject.com/internet/ipaddress.asp[^] now I'm on my way to the solution. Thanks again!

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

                  lucy wrote:

                  I then found this article: http://www.codeproject.com/internet/ipaddress.asp\[^\]

                  It seems to have an unnecessary call to gethostname(), as szHostName is not used for anything. :confused:


                  "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                  "Judge not by the eye but by the heart." - Native American Proverb

                  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