Socket Programming using UDP

 What is UDP?

Server Side

import socket

UDP_IP = "127.0.0.1"

UDP_PORT = 5018


sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)

sock.bind((UDP_IP, UDP_PORT))

print("IP address:",UDP_IP)

print("port no.:",UDP_PORT)

data, addr = sock.recvfrom(1024)

print(data)

print(addr)

Client Side

import socket


UDP_IP = "127.0.0.1"

UDP_PORT = 5018


message=b"Hello World"

print("IP address",UDP_IP)

print("Port number ",UDP_PORT)

print(message)

sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)


sock.sendto(message,(UDP_IP, UDP_PORT))