import socket
udp_soc = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # 创建套接字
local_address = ('', 1234)
udp_soc.bind(local_address) # 绑定端口
data = input("please, input your data:")
udp_soc.sendto(data.encode('utf-8'), ('172.28.136.150', 8080)) # 发送数据,包含对方IP和port
udp_soc.close() # 关闭套接字
python 使用udp协议发送数据
猜你喜欢
转载自blog.csdn.net/sinat_32152019/article/details/89332567
今日推荐
周排行