def recv(self, length=1024):
        """
        Receive a message from the socket.

        Args:
            length (int, optional): The maximum amount of data to be received at once. Default is 1024.

        Returns:
            dict: The deserialized JSON message received, or None if the message is not well-formed.

        """
        # The length parameter can be altered to fit the size of the message
        buffer = ""
        while True:
            msg = self.sock.recv(length).decode("utf-8")
            if not msg:
                break
            buffer += msg

            if "\n" in buffer:
                # Split the buffer at the newline to process the complete message
                complete_msg, _, buffer = buffer.partition("\n")

                # Attempt to deserialize the JSON data
                try:
                    return json.loads(
                        complete_msg
                    )  # Return the deserialized dictionary
                except json.JSONDecodeError:
                    # Handle error if JSON is not well-formed
                    break  # Or handle error accordingly
        return None

        Receive a message from the socket.

        Args:
            length (int, optional): The maximum amount of data to be received at once. Default is 1024.

        Returns:
            dict: The deserialized JSON message received, or None if the message is not well-formed.

        
llama-index-packs/llama-index-packs-secgpt/llama_index/packs/secgpt/sock.py