Broadcasting Without the Broadcast Address

Before you can broadcast, you must know the appropriate broadcast address for your subnet. In the previous examples, we hard-coded that address; but for portable, general-purpose utilities, it would be nice not to have to do this.

The are two ways to broadcast if you don't know the correct broadcast address in advance. One is to use the all-ones broadcast address as the target. The other is to determine the host's broadcast address at runtime.

The All-Ones Broadcast Address

The easiest way to broadcast when you don't know the subnet-directed broadcast address in advance is to use the all-ones broadcast address, 255.255.255.255. This address was developed primarily for use by diskless workstations, ...

Get Network Programming with Perl now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.