socket默认不支持地址复用,如果要复用需要显示设定,即在绑定前调用setsockop函数t让套接字允许地址重用:socket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) s.bind((‘‘, UDP_PORT))
2023-10-17 21:56:10
socket默认不支持地址复用,如果要复用需要显示设定,即在绑定前调用setsockop函数t让套接字允许地址重用:socket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) s.bind((‘‘, UDP_PORT))