0
我想開發一個局域網搜索工具。爲此,我需要所有連接的主機IP。爲此,我正在使用它,但它對我無效。它會讓所有結果都無法訪問,即使是我自己的IP。在java中連接到局域網的所有主機的geting ip地址
請幫我什麼在這個
public static void checkHosts(String subnet) throws UnknownHostException, IOException{
int timeout=1000;
for (int i=1;i<254;i++){
System.out.println(i);
String host=subnet + "." + i;
if (InetAddress.getByName(host).isReachable(timeout)){
System.out.println(host + " is reachable");
}
else{
System.out.println(host + " is not reachable");
}
}