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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.