标签:消息 传输 pre soc color int imp span print
服务端
from socket import * #创建套接字 ip_port = (‘192.168.0.143‘,8888) udp_socket = socket(AF_INET,SOCK_DGRAM) udp_socket.bind(ip_port) #消息传输 print("等待接收") data,addr = udp_socket.recvfrom(20) print("接收到",data) #关闭套接字 udp_socket.close()
客户端
from socket import * udp_socket = socket(AF_INET,SOCK_DGRAM) #消息传输 server_address = (‘192.168.0.143‘,8888) udp_socket.sendto(b‘Hello World‘,server_address) #关闭套接字 udp_socket.close()
标签:消息 传输 pre soc color int imp span print
原文地址:https://www.cnblogs.com/gao-chao/p/13254030.html