Skip to content

Instantly share code, notes, and snippets.

@roberthartung
Last active September 18, 2015 11:34
Show Gist options
  • Save roberthartung/e3073eca4435735bf3cd to your computer and use it in GitHub Desktop.
Save roberthartung/e3073eca4435735bf3cd to your computer and use it in GitHub Desktop.
#!/usr/bin/python
data = self.request.recv(4)
if len(data) == 0:
print "Length is 0. Aborting."
break
length = struct.unpack("I", data)[0]
offset = 0
all_data = []
while offset < length:
tmp_data = self.request.recv(length-offset)
if len(tmp_data) == 0:
print "Length is 0. Aborting."
break
offset += len(tmp_data)
all_data.append(tmp_data)
data_str = ''.join(tmp_data)
message = cPickle.loads(data_str)
print message, message.number, message.rate, message.samples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment