problems using magic "<broadcast>" socket address on different platforms

Cecil H. Whitley cwhitley at earthlink.net
Thu May 1 21:30:05 EDT 2003


Hi,
The broadcast address is dependant upon the ip address and subnet mask.
255.255.255.255 is a generalization much like 0.0.0.0 for "default gateway".
If I remember correctly you can calculate it using
network addr xor (subnet mask xor 255.255.255.255)
example:
192.168.1.0 (network addr)
subnet mask 255.255.255.0 (standard class c)
yields
192.168.1.0 xor (255.255.255.0 xor 255.255.255.255)
yields
192.168.1.0 xor 0.0.0.255
yields
192.168.1.255 which is the proper broadcast address.

Regards,
Cecil






More information about the Python-list mailing list