Sending and Receiving Broadcasts

Broadcasting a message is simply a matter of sending a UDP message to the broadcast address for your subnet. A simple way to see broadcasts in action is to use the ping program to send an ICMP ping request to the broadcast address. The following example illustrates what happened when I pinged the broadcast address for my office's 143.48.31.0/24 network:

% ping 143.48.31.255 PING 143.48.31.255 (143.48.31.255): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=4.9 ms 64 bytes from 143.48.31.46: icmp_seq=0 ttl=255 time=5.4 ms (DUP!) 64 bytes from 143.48.31.52: icmp_seq=0 ttl=255 time=5.9 ms (DUP!) 64 bytes from 143.48.31.47: icmp_seq=0 ttl=255 time=6.4 ms (DUP!) 64 bytes from 143.48.31.48: icmp_seq=0 ...

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.