from threading import Thread
from socket import *
udp_s=socket(AF_INET,SOCK_DGRAM)
dest_address=(‘10.10.107.44’,9124)
local_address=((‘10.10.107.80’,8888))
udp_s.bind(local_address)
def a():
while True:
data=input(“请输入数据”)
udp_s.sendto(data.encode(‘utf-8’),dest_address)
# s=udp_s.recvfrom(124)
# print(s[0].decode(‘utf-8’))
def b():
while True:
s = udp_s.recvfrom(124)
print(s[0].decode(‘utf-8’))
if name == ‘main’:
t1=Thread(target=a)
t2=Thread(target=b)
t1.start()
t2.start()
06-18
2600