managing Modem connections using Java

1

I need to know if there is any class (s) that can get properties from the connections of the devices connected to the modem network.

    
asked by Asahi Sara 13.06.2016 в 03:01
source

1 answer

1

It is not very clear to me what you intend to do but I leave you a code that goes through the network connections and shows you the ips of the computers connected at the moment under a range of ips

public void checkHosts(String subnet){
   int timeout=1000;
   for (int i=1;i<255;i++){
       String host=subnet + "." + i;
       if (InetAddress.getByName(host).isReachable(timeout)){
           System.out.println(host + " Encontrado");
       }
   }
}

For the subnet (192.168.0.1-254)

checkHosts("192.168.0");

Once you have obtained a Host, you can check its properties

// InetAddress address = InetAddress.byName ... 


System.out.println("Host Address: "+ address.getHostAddress());
System.out.println("Host Name: "+ address.getHostName());
System.out.println("CanonicalHostName: "+ address.getCanonicalHostName());
System.out.println("Address: "+ address.getAddress());
System.out.println("LocalHost: "+ address.getLocalHost());
System.out.println("LoopbackAddress: "+ address.getLoopbackAddress());
    
answered by 13.06.2016 в 03:06