Created
February 7, 2015 18:15
-
-
Save hackcasual/97f448aa8b22ec00dba0 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
#!/usr/bin/python | |
import socket | |
import zlib | |
import numpy as np | |
WIDTH = 256 | |
HEIGHT = 128 | |
buf = np.zeros(WIDTH * HEIGHT * 3 + 1, np.uint8) | |
buf[0] = 1 | |
for i in range(1, len(buf)): | |
buf[i] = 255 | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
sock.setsockopt(socket.SOL_SOCKET,socket.SO_SNDBUF,int(256 * 128 * 3)) | |
compBuf = zlib.compress(buf.tostring()) | |
print(ord(buf.tostring()[0])) | |
sock.sendto(compBuf, ("192.168.1.189", 9999)) | |
print(ord(zlib.decompress(compBuf)[0])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment