[IMP] merge two socket.recv into one.

bzr revid: florent.xicluna@gmail.com-20120123143015-gz22l5qre6ria8f4
This commit is contained in:
Florent Xicluna 2012-01-23 15:30:15 +01:00
parent c749cd8fcc
commit bac1a95719
1 changed files with 5 additions and 6 deletions

View File

@ -72,15 +72,14 @@ class mysocket:
def myreceive(self):
buf=''
while len(buf) < 8:
chunk = self.sock.recv(8 - len(buf))
while len(buf) < 9:
chunk = self.sock.recv(9 - len(buf))
if not chunk:
raise socket.timeout
buf += chunk
size = int(buf)
buf = self.sock.recv(1)
if buf != "0":
exception = buf
size = int(buf[:8])
if buf[8] != "0":
exception = buf[8]
else:
exception = False
msg = ''