get current url of a java network

Asked

Viewed 458 times

0

I need some way to get the url’s accessed on a computer network, I’ve seen enough, I found a code that uses socket but it’s a host only, but cannot be of a host individual, I want the whole network, some class or an example of how to do this

ps:not a server servlet

1 answer

1

I didn’t understand it very well, but this takes all the hosts of a lan

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

//call
checkHosts("192.168.0");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.