mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
Merge.
This commit is contained in:
commit
debcb9dd54
1 changed files with 7 additions and 5 deletions
|
@ -204,13 +204,15 @@ length message::
|
||||||
totalsent = totalsent + sent
|
totalsent = totalsent + sent
|
||||||
|
|
||||||
def myreceive(self):
|
def myreceive(self):
|
||||||
msg = b''
|
chunks = []
|
||||||
while len(msg) < MSGLEN:
|
bytes_recd = 0
|
||||||
chunk = self.sock.recv(MSGLEN-len(msg))
|
while bytes_recd < MSGLEN:
|
||||||
|
chunk = self.sock.recv(min(MSGLEN - bytes_recd, 2048))
|
||||||
if chunk == b'':
|
if chunk == b'':
|
||||||
raise RuntimeError("socket connection broken")
|
raise RuntimeError("socket connection broken")
|
||||||
msg = msg + chunk
|
chucks.append(chunk)
|
||||||
return msg
|
bytes_recd = bytes_recd + len(chunk)
|
||||||
|
return b''.join(chunks)
|
||||||
|
|
||||||
The sending code here is usable for almost any messaging scheme - in Python you
|
The sending code here is usable for almost any messaging scheme - in Python you
|
||||||
send strings, and you can use ``len()`` to determine its length (even if it has
|
send strings, and you can use ``len()`` to determine its length (even if it has
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue