Hi all, I have a problem :
I was writing a little program that display all ip (all host) connected to my router and so in my same subnetwork.
Now I'll show my idea:
Code :private boolean pingHost(InetAddress ip) throws IOException{ if(ip.isReachable(1000)){ System.out.println(ip.toString() +"IS REACHABLE"); return true; } else{ return false; }
I have made this to generate all ip in my range:
Code :private ArrayList<InetAddress> generateAllSubnetIP(InetAddress localHostIP){ ArrayList<InetAddress> allsubnetIP = new ArrayList<InetAddress>(); byte[] localIPbyte = localHostIP.getAddress(); for (int i = 0; i < 256; i++) { byte[] tempIP={localIPbyte[0],localIPbyte[1],localIPbyte[2],(byte)i}; try { allsubnetIP.add(InetAddress.getByAddress(tempIP)); } catch (UnknownHostException e) { System.out.println("UnknownHost generating all ip address"); e.printStackTrace(); } } return allsubnetIP; }
and then I call pingHost for all the ip stored in the ArrayList.
but this doesn't work...
Any idea ?
I hope that you can understand my question...if not ask me for more details...
Thank you...
