更新时间:2022-12-08 15:18:43
您正在尝试发送到广播地址.这是不允许的,请参阅 sendto(2) 的手册页:
You are trying to send to a broadcast address. It is not allowed, see manpage for sendto(2):
EACCES(对于 UDP 套接字)尝试发送到网络/广播地址,就好像它是单播地址一样.
EACCES (For UDP sockets) An attempt was made to send to a network/broadcast address as though it was a unicast address.
设置 SO_BROADCAST 选项,如果您实际上是要发送到广播地址:
Set the SO_BROADCAST option, if you actually mean to send to a broadcast address:
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)