Currently I've got a working port scanner but I want to limit it to only scanning IP address on the local subnet.
The only solution i've found when digging is this: Does anyone know a java component to check if IP address is from particular network/netmask? however I dont full understand
What is the difference between a subnet and a netmask? I thought they were the same thing?
Secondly, how can i find the values for subnet and netmask for localHost?
So far this is what I have
NetworkInterface network = NetworkInterface.getByInetAddress(localHost);
short subnetMask =
network.getInterfaceAddresses().get(1).getNetworkPrefixLength();
But is this the netmask or the subnet? And how do I get the other value?