Skip to content

Instantly share code, notes, and snippets.

@linmic
Created December 29, 2013 04:59
Show Gist options
  • Save linmic/8167610 to your computer and use it in GitHub Desktop.
Save linmic/8167610 to your computer and use it in GitHub Desktop.
listen thru udp
#!/usr/bin/python
# receive udp packets from all interfaces
import socket
HOST = '' # use '' to expose to all networks
port = 5464
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((HOST, port))
try:
while True:
data, addr = s.recvfrom(4096)
back = 'Your address is %r\n' % (addr,)
print data
except KeyboardInterrupt:
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment