How can I send broadcast packets in Java?

Tim Rohaly

Broadcasting is defined as sending a packet to all network nodes on a subnet. An IP network subnet mask divides an IP address into two parts: the network identifier and the node identifier. A broadcast address is defined as an IP address where all bits of the node identifier are set. For example, www.jguru.com has an IP address of and a subnet mask of In this case, the network identifier is 216.217.9, and the node identifier is 172. Using the above definition, the broadcast address for this subnet would be

So, sending a broadcast packet from a Java program (or from a program in any other language, for that matter) simply requires you to specify the broadcast address as the destination for the packet.