sockets - Why do we need SocketOptions.SO_BROADCAST to enable broadcast? -
if want broadcast information socket, need enable socketoptions.so_broadcast. however, don't understand why necessary.
my understanding set packet broadcast address, same way set unicast address. need send through regular socket. if udp socket, udp header added packet, , ip header containing receiver's ip address (in case broadcast address in form of 192.168.255.255), , mac address (ff:ff:ff:ff) added.
i think router packet , perform broadcast. don't understand why need set socket attribute so_broadcast.
"socket semantics require application set so_broadcast option on before attempting send datagram base or broadcast address. protects application accidentally sending datagram many systems."