async def METHOD_NAME(loop, factory, sock):
    """Create a datagram connection that uses recvmsg rather than recvfrom, and
    a RecvmsgDatagramProtocol protocol type.
    This is used like the create_datagram_endpoint method of an asyncio loop,
    but implemented in a generic way using the loop's add_reader method; thus,
    it's not a method of the loop but an independent function.
    Due to the way it is used in aiocoap, socket is not an optional argument
    here; it could be were this module ever split off into a standalone
    package.
    """
    sock.setblocking(False)
    protocol = factory()
    waiter = loop.create_future()
    transport = RecvmsgSelectorDatagramTransport(
            loop, sock, protocol, waiter)
    try:
        await waiter
    # see https://github.com/PyCQA/pycodestyle/issues/703
    except: # noqa: E722
        transport.close()
        raise
    return transport, protocol