Last active
February 19, 2025 09:50
-
-
Save abdalmoez/bfc0df47f47bda90c5ac218e93be9eeb to your computer and use it in GitHub Desktop.
Send udp packet using python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
UDP_IP = "127.0.0.1" | |
UDP_PORT = 1234 | |
MESSAGE = "Hello, World!" | |
print ("UDP target IP:", UDP_IP) | |
print ("UDP target port:", UDP_PORT) | |
print ("message:", MESSAGE) | |
sock = socket.socket(socket.AF_INET, # Internet | |
socket.SOCK_DGRAM) # UDP | |
sock.sendto(MESSAGE.encode(), (UDP_IP, UDP_PORT)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment