Last active
August 3, 2016 13:29
-
-
Save sparrc/42422743b72bdfe172e00b95933f87b6 to your computer and use it in GitHub Desktop.
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
import socket | |
SOCKET_SIZE = 4096 | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
sock.bind(("localhost", 8009)) | |
sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, SOCKET_SIZE) | |
while True: | |
try: | |
msg, host = sock.recvfrom(SOCKET_SIZE) | |
# print(msg) | |
print("RECV {} byte payload from {}:{} ->\n{}"\ | |
.format(len(str(msg)), host[0], host[1], msg)) | |
except KeyboardInterrupt: | |
print("") | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment