udpserver测试小程序
import socket,sys,binascii ip = '127.0.0.1' port = 9999 s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) s.bind((ip,port)) print(f'绑定端口:{port}...') while True: data , addr = s.recvfrom(1024) print('接收到: %s:%s.' % addr , '发来的消息:',binascii.b2a_hex(data)) print('-' * 30 , 'OVER','-' * 30) s.sendto(data,addr)