初见UDP_Client
from socket import *
ip_prot = ('192.168.55.1',8080)
buffer_size = 1024
udp_client = socket(AF_INET,SOCK_DGRAM) #DGRAM--数据报式套接字
while True:
msg = input('>>>').strip()
udp_client.sendto(msg.encode('utf-8'),ip_prot)
data,addr =udp_client.recvfrom(buffer_size)
print(data.decode('utf-8'))
Win a contest, win a challenge
posted on 2018-03-09 16:31 pandaboy1123 阅读(102) 评论(0) 编辑 收藏 举报