Skip to content

Instantly share code, notes, and snippets.

@oliora
Last active August 11, 2023 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oliora/c010bd4bf2529e9d853fd06686cfe50f to your computer and use it in GitHub Desktop.
Save oliora/c010bd4bf2529e9d853fd06686cfe50f to your computer and use it in GitHub Desktop.
Trivial UDP sender in Python
# 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