解决python的socket编程报Errno 98的问题
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))