diff options
author | Florian Jung <flo@windfisch.org> | 2014-12-20 21:28:38 +0100 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2014-12-20 21:28:38 +0100 |
commit | ce289fe207c844d8cf8dcfc96881ad064b19eef0 (patch) | |
tree | 5012e20d0f7fee4473e3e6bf74ef3707d2a727c9 /server.py | |
parent | 6982b27c2fd9009dc56de87c513b36b363768795 (diff) |
OARRRRR
Diffstat (limited to 'server.py')
-rw-r--r-- | server.py | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -3,6 +3,12 @@ import os import socket import sys +def encode_int(i): + i = int(i) + return chr( (i/(2**24))%256) + chr( (i/(2**16))%256 ) +\ + chr( (i/(2**8))%256) + chr(i%256) + + server_address = '/home/flo/uds_socket' try: os.unlink(server_address) @@ -35,8 +41,13 @@ while True: if data: if data=="get\n": status, frame = cap.read() - print >>sys.stderr, 'sending image to the client' - connection.sendall(frame.tostring()) + framestr = frame.tostring() + lenframestr=len(framestr) + print hex(lenframestr) + for i in xrange(0,4): + print hex(ord(encode_int(lenframestr)[i])) + print 'sending ',lenframestr,' bytes to the client' + connection.sendall(encode_int(lenframestr)+framestr); cv2.imshow("img",frame) cv2.waitKey(20) else: |