def METHOD_NAME(protocol=TCP, manager_port=1514):
    """Check the communication between the agent-manager using different protocols.
    Args:
        protocol (str): It can be only TCP or UDP.
        manager_port (int): Manager remote communication port.
    Raises:
        ConnectionRefusedError: If communication could not be established with the socket.
        TimeoutError: If the event could not be found in the socket queue.
    """
    def send_event(event, protocol, manager_port):
        """Send an event to the manager"""
        print(f"Sending {protocol}")
        sender = ag.Sender(agent_info['manager_address'], protocol=protocol, manager_port=manager_port)
        try:
            sender.send_event(event)
        finally:
            sender.socket.close()
    # Create agent and sender
    agent = ag.Agent(manager_address=agent_info['manager_address'], os=agent_info['os'], version=agent_info['version'])
    # Wait until remoted has loaded the new agent key
    rd.wait_to_remoted_key_update(wazuh_log_monitor)
    # Generate a custom event
    search_pattern = f"test message from agent {agent.id}"
    agent_custom_message = f"1:/test.log:Feb 23 17:18:20 manager sshd[40657]: {search_pattern}"
    event = agent.create_event(agent_custom_message)
    send_event_thread = ThreadExecutor(send_event, {'event': event, 'protocol': protocol, 'manager_port': manager_port})
    # If protocol is TCP, then just send the message as the attempt to establish the connection will fail.
    if protocol == TCP:
        send_event_thread.start()
        send_event_thread.join()
    else:  # If protocol is UDP, then monitor the  socket queue to verify that the event has not been received.
        socket_monitor_thread = ThreadExecutor(rd.check_queue_socket_event, {'raw_events': search_pattern,
                                                                             'timeout': 20})
        socket_monitor_thread.start()
        # Wait 3 seconds until socket monitor is fully initialized
        sleep(3)
        send_event_thread.start()
        send_event_thread.join()
        # Wait until socket monitor thread finishes
        socket_monitor_thread.join()