MCPcopy Create free account
hub / github.com/Apress/python-for-matlab-development / wait_for_nBytes

Function wait_for_nBytes

code/IO/tcp/client.py:35–47  ·  view source on GitHub ↗
(n, Sock)

Source from the content-addressed store, hash-verified

33import struct
34
35def wait_for_nBytes(n, Sock):
36 Bytes = b''
37 received = 0
38 block_size = 2048
39 while received < n:
40 data = Sock.recv(min(n-received, block_size))
41 if not data:
42 break
43 Bytes += data
44 received += len(data)
45 if len(Bytes) == n:
46 break
47 return Bytes
48
49def main():
50 Host, Port = '127.0.0.1', 5006

Callers 2

mainFunction · 0.90
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected