Why do we need SocketOptions.SO_BROADCAST to enable broadcast?

后端 未结 2 1138
春和景丽
春和景丽 2021-01-03 22:29

If we want to broadcast information from a socket, we need to enable SocketOptions.SO_BROADCAST. However, I don\'t understand why that is necessary.

My

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-03 23:20

    "Socket semantics require that an application set the SO_BROADCAST option on before attempting to send a datagram to a base or broadcast address. This protects the application from accidentally sending a datagram to many systems."

    Source

提交回复
热议问题