Using the Apache Commons Net library, why does the following output 0 addresses for the CIDR notation 127.0.0.1/32 ? I'd have expected one, or am I misunderstanding something? Is the address 127.0.0.1 not in the specified range?
SubnetInfo rangeInfo = new SubnetUtils("127.0.0.1/32").getInfo();
System.out.println(rangeInfo.getAddressCount());
I haven't tested it yet, but it appears that the variable rangeInfo
is not set. If that is just a typo, this may get you the correct number of hosts.
SubnetInfo info = new SubnetUtils("127.0.0.1/32").getInfo();
info.setInclusiveHostCount(true);
System.out.println(info.getAddressCount());