1####### UDP Server #######
2
3from socket import socket,AF_INET , SOCK_DGRAM
4
5sobj = socket(AF_INET,SOCK_DGRAM)
6
7
8ip = '127.0.0.1'
9port = 20000
10
11sobj.bind((ip,port))
12
13while True:
14 msg = sobj.recvfrom(2048)
15 print(msg)
16
17####### UDP Client #######
18
19from socket import socket,AF_INET , SOCK_DGRAM
20
21sobj = socket(AF_INET,SOCK_DGRAM)
22
23
24ip = '127.0.0.1'
25port = 20000
26
27msg = "Hello World"
28sobj.sendto(msg.encode(),(ip,port))