UDP communication is similar to sending text messages, only need to know the ip and port of the other party; and does not need to establish a connection.
import socket#Create socket objects=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)#AF_INET ipv4 protocol SOCK_DGRAM udp modehost = socket.gethostname()#Get local computer nameip = socket.gethostbyname(host)#Get local computer ipport = 1000#set port numbers.bind((ip, port)) #Bind local ip and portprint("udp configuration complete")print("udp ip ",ip," port",port)while(1):data,addr=s.recvfrom(1024) #Receive 1024 bytes at a timeprint(data.decode(),addr)# decode() decodes the received bytess.sendto(data.upper(),addr)s.close()