Skip to content

Instantly share code, notes, and snippets.

@hackcasual
Created February 7, 2015 18:15
Show Gist options
  • Save hackcasual/97f448aa8b22ec00dba0 to your computer and use it in GitHub Desktop.
Save hackcasual/97f448aa8b22ec00dba0 to your computer and use it in GitHub Desktop.
#!/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