Discussion Forum | Board Infinity

Draft a Python code to create datagram

Python Code to Create Datagarm.

import socket
UDP_IP = “localhost”
UDP_PORT = 5050
MESSAGE = "Hello UDP! "
print ("Sent Message: ", MESSAGE)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.sendto(bytes(MESSAGE, “utf-8”), (UDP_IP, UDP_PORT))