Last active
August 11, 2023 13:21
-
-
Save oliora/c010bd4bf2529e9d853fd06686cfe50f to your computer and use it in GitHub Desktop.
Trivial UDP sender in Python
This file contains 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
# Run it like `python3 udp-send.py <detination_addr> <destination_port> [<interface_to_bind>]` | |
import socket | |
import sys | |
with socket.socket(type=socket.SOCK_DGRAM) as s: | |
if len(sys.argv) >= 4: | |
s.bind((sys.argv[3], 0)) | |
s.connect((sys.argv[1], int(sys.argv[2]))) | |
s.send(b'Hello!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment