Do UDP broadcasts work in FreeBSD?

Peter Steele psteele at maxiscale.com
Thu Jan 8 08:23:26 PST 2009


>Did you enable SO_BROADCAST and IP_ONESBCAST on the socket? I remember
needing 
>this on FreeBSD but not on Linux.

Yes we did, but...

>I know UDP broadcasting works fine, but is 
>somewhat more involved:
>
>addr.sin_family = AF_INET;
>addr.sin_addr.s_addr = inet_addr("130.89.191.255");
>addr.sin_port = htons(UDP_PORT_ET);

You are using a subnet broadcast here. We are dealing with systems that
do not have IPs assigned, and as a result we have to send our broadcasts
to 255.255.255.255. This works fine on other operating systems but for
some reason the implementation is different on FreeBSD. It appears that
the only way this kind of broadcast can be sent on FreeBSD is using raw
sockets. This is how the FreeBSD DHCP client/server is written, so we're
taking that approach as well...




More information about the freebsd-questions mailing list