0
我想通過UDP(我使用json.dumps的字典列表)發送消息,並且出現此錯誤: OSError:[WinError 10040]數據報套接字大於內部消息緩衝器或某種其它網絡的限制,或用於接收數據報的緩衝區更大比數據報小劃分udp數據報消息
這是客戶端代碼:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server_address = (SRVR_NAME,DST_PORT)
packet_info = json.dumps(packet_info)
packet_info = packet_info.encode()
sock.sendto(packet_info,server_address)
sock.close()
這是服務器端代碼:
listening_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server_address = (IP, PORT)
listening_sock.bind(server_address)
client_msg, client_addr = listening_sock.recvfrom(MSG_SIZE)
d = json.loads(client_msg)
d = d.decode()
print(d)