We have a router and 3 PCs connected.
- PC1: 192.168.1.2 (wireless)
- PC2: 192.168.1.3 (wireless)
- PC3: 192.168.1.6
Default gateway: 192.168.1.1
When PC3 tried to find connected PCs using the code from this forum post, it only returns the IP address of the default gateway (That address is the only reachable address).
I tried increasing the timeout for the isReachable()
method. But still it returns only the default gateway address.
I tried doing this to the individual IP addresses.
try {
InetAddress temp2 = InetAddress.getByAddress(new byte[]{(byte) 192, (byte) 168, (byte) 1, (byte) 2});
if (temp2.isReachable(1100)) {
java.lang.System.out.println("IP Address: " + temp2.getHostAddress() + " has connection.");
}else{
java.lang.System.out.println("IP Address: " + temp2.getHostAddress() + " has no connection.");
}
} catch (Exception ex) {
java.lang.System.out.println("Error: " + ex.getMessage());
}
Yet doing on those PC1 and PC2 IP addresses, I only got a no connection status. (Which means those IPs are not reachable.)
But when I ping them on my windows console those IPs are connected and pinging is successful.
- What is the problem with my setup.
- How can I resolve this.