How can I determine the subnet mask and IP broadcast address?

Tim Rohaly

Java currently has no facility for determining a subnet mask. A subnet mask is used to denote which bits in an IP address are the "network" part and which bits are the "machine" part. A broadcast address has all the "machine" bits set to 1, so you need to know the subnet mask in order to programmatically determine the IP broadcast address.