def METHOD_NAME(self, length):
    r = bytes()
    while len(r) < length:
        rn = self.socket.recv(min(8192, length - len(r)))
        if not rn:
            raise ConnectionResetError("Connection closed")
        r += rn
    return r