Skip to content

Instantly share code, notes, and snippets.

@DenchiSoft
Created August 28, 2021 14:59
Show Gist options
  • Save DenchiSoft/51cd5c967ef3b77d957ec136ecf443d2 to your computer and use it in GitHub Desktop.
Save DenchiSoft/51cd5c967ef3b77d957ec136ecf443d2 to your computer and use it in GitHub Desktop.
import socket
from socket import timeout
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
s.bind(("0.0.0.0", 47779));
s.settimeout(0.5)
while True:
try:
data, address = s.recvfrom(4096)
print("Received: ", data.decode('utf-8'))
except timeout:
print("Scanning for broadcasts")
s.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment