Created
December 29, 2013 04:59
-
-
Save linmic/8167610 to your computer and use it in GitHub Desktop.
listen thru udp
This file contains hidden or 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/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