Announcement

Collapse
No announcement yet.

LAN Subnet

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    LAN Subnet

    Hiya.
    Just wondering how to obtain an list of IP addresses on
    a subnet/workgroup. I want my client software to get a list of
    IP's in a workgroup and test each one for and active copy
    of my server (rather than have a user set each workstation enter
    a server IP manualy)
    Trying to avoid shared drives etc !

    Any help appreciated.

    N.


    ------------------

    #2
    One way to accomplish the task would be for the 'client' to do a UDP broadcast to a specific port, and listen to that port for a response.

    A server app would listen on that port for a broadcast and respond with it's I/P address. When the client gets that response, it knows the server I/P address. If none is received after a few goes, it can assume the server role itself.

    To get the broadcast address, say the machines are all addressed 192.168.0.x, the broadcast address for the segment will be 192.168.0.255.

    Easy to derive with HOST ADDR:
    Code:
        prt& = 16000
        HOST ADDR TO ip&
        bip& = (ip& OR &HFF000000)
        ' ip& is local IP, bip is broadcast IP.
    Now a UDP SEND to bip& will go to all machine on the segment.

    You could also use this idea to have each machine respond with it's own I/P address to gather data, by doing another broadcast from the server.

    UDP is excellent for this kind of app...




    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


      #3
      Thanx Lance,
      Thats got me on the right track, never played with UDP before.
      I will just have to hope that all machines in the subnet/workgroup
      are using the same IP range, if not then they will just have to
      enter a server IP address

      TA.
      N.



      ------------------

      Comment


        #4
        Another, less resource-intensive solution is to add any host that is running your application into a multicast group, so that the message you are sending will only be picked up by those clients. It cuts down on broadcasts.

        How IP Multicast Works http://www.ipmulticast.com/community...ipmcworks.html

        Writing IP Multicast-enabled Applications http://www.ipmulticast.com/community.../ipmcapps.html

        FF.



        ------------------

        Comment


          #5
          I've never tried multi-casting - sounds quite interesting... anyone here tried it (with PowerBASIC)?



          ------------------
          Lance
          PowerBASIC Support
          mailto:[email protected][email protected]</A>
          Lance
          mailto:[email protected]

          Comment


            #6
            Lance.

            Just tried your method at work, seemed to do the job just fine.
            Only prob I had was that I forgot about the two NICs in my
            machine and of course HOST ADDR picked the first one it found
            which just happened to be my Static IP to the outside world.
            Needless to say my ISP wasnt too happy

            Any Ideas on how to use the UDP Idea but using the
            subnet mask ?

            ------------------

            Comment


              #7
              I don't know if the multi-cast covers this or not, but somehow you should be able to do an arp broad cast....this is lower than the network level...
              If a cisco router is in place there is a way to use ICMP to recover all IP addresses on the subnet, but I forgot what command it is in ICMP....it would be difficult I think....maybe not...



              ------------------
              Scott Turchin
              MCSE, MCP+I
              Computer Creations Software
              http://www.tngbbs.com/ccs
              Scott Turchin
              MCSE, MCP+I
              http://www.tngbbs.com
              ----------------------
              True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

              Comment


                #8
                A similar thing to what I want to do would be the windows
                DHCP client & server. The client finds the server before
                even a subnet is entered. would this be using ICMP ?

                ------------------

                Comment


                  #9
                  Well, pick a different IP from the IP table...
                  Code:
                  x& = 1
                  DO
                    HOST ADDR(x&) TO ip&
                    '... store it or whatever
                  LOOP UNTIL ISFALSE ip&
                  There is a bug in HOST ADDR in that it crashes on the 6th try (or something like that), but you should only enumerate the IP list until the IP returns zero.

                  So until the next update you could try some of the IP-discover code posted in recent times to the Source Code forum.



                  ------------------
                  Lance
                  PowerBASIC Support
                  mailto:[email protected][email protected]</A>
                  Lance
                  mailto:[email protected]

                  Comment

                  Working...
                  X
                  😀
                  🥰
                  🤢
                  😎
                  😡
                  👍
                  👎