socket.setBroadcast(flag)


设置或清除 SO_BROADCAST 套接字选项。 当设置为 true 时,UDP 数据包可能会被发送到本地接口的广播地址。

如果在未绑定的套接字上调用此方法将抛出 EBADF

Sets or clears the SO_BROADCAST socket option. When set to true, UDP packets may be sent to a local interface's broadcast address.

This method throws EBADF if called on an unbound socket.