code: def recvall(sock, size):
      
      data = b""
      while len(data) < size:
          s = sock.recv(size - len(data))
          data += s
          if not s:
              raise RuntimeError("did not receive data from socket "
                                 "(size {}, got only {!r})".format(size, data))
      return data
docs: Receive data of given size from a socket connection