I want to check all of nodes accessibility in a network using java. I have read This and This Questions and I have write my method by helping these questions, I have at least two tested Ips in my network which are accessible, one of them is 192.168.1.1
and another is 192.168.1.102
you can see test of 192.168.1.1
in the below picture:
Odk but when I run my code my app says that 192.168.1.1 is not reachable. here is the image, I have pointed at it with a red arrow:
ok , and here is my java code:
private void checkNetworkAccessibility(){
int timeout = 1000;
String subnet = firstSubnet.getText() + "." + secondSubnet.getText() + "." + thirdSubnet.getText() + ".";
DefaultTableModel model = (DefaultTableModel)networkTable.getModel();
for(int i=1;i<=254;i++){
try {
if(InetAddress.getByName(subnet+i).isReachable(timeout)){
model.addRow(new Object[]{subnet + i, subnet + i, "بله", "بله"});
}
else{
model.addRow(new Object[]{subnet + i, "نامشخص", "خیر", "بله"});
}
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
}
}
what is wrong with my code?