Created
January 12, 2024 07:23
-
-
Save brettbeeson/e2a2188d950de48d5561897c515f4a68 to your computer and use it in GitHub Desktop.
Echo bytes from UDP port to stdout, treating as utf-8
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
#!/usr/bin/env python3 | |
# Based on: David Manouchehri <manouchehri@protonmail.com> | |
# Echo bytes from UDP port to stdout, treating as utf-8 | |
import socket | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
server_address = '0.0.0.0' | |
server_port = 22222 | |
server = (server_address, server_port) | |
sock.bind(server) | |
print("Listening on ", server_address, ":", str(server_port), flush=True) | |
while True: | |
payload, client_address = sock.recvfrom(1000) | |
print(payload.decode(),end='',flush=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment