import socket


def _receive_devices(port: int, sock: socket.socket, devices: list) -> list:
    """
    After sending the device discovery request, collect all available 
        devices

    Args:
        port (int): Local port
        sock (socket.socket): Socket object
        devices (list): List of available devices.
            [(device_name: str, ip: str)]

    Returns:
        list: Updated list of available devices.
            [(device_name: str, ip: str)]
    """
    try:
        while True:
            data, _ = sock.recvfrom(port)
            split_data = data.decode("utf-8").split(":")
            if len(split_data) == 3:
                devices.append((split_data[0].strip(), split_data[2].strip()))
            else:
                raise ValueError(data)
    except (socket.timeout, OSError):
        pass
    return devices