We have a router and 3 PCs.
- 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 of this forum post , it returns the IP address of the default gateway (this address is the only available address).
I tried to increase the timeout for the method isReachable(). But still, it only returns the default gateway address.
I tried to do this with separate 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());
}
However, on those IP addresses PC1 and PC2, I got the connection status. (This means that these IP addresses are not available.)
But when I ping them on my Windows console, these IP addresses are connected, and pinging is successful.
- What is the problem with my setup.
- How can i solve this.