def sendmsg(socket, data, ancillary=[], flags=0):
    """
    Send a message on a socket.

    @param socket: The socket to send the message on.
    @type socket: L{socket.socket}

    @param data: Bytes to write to the socket.
    @type data: bytes

    @param ancillary: Extra data to send over the socket outside of the normal
        datagram or stream mechanism.  By default no ancillary data is sent.
    @type ancillary: C{list} of C{tuple} of C{int}, C{int}, and C{bytes}.

    @param flags: Flags to affect how the message is sent.  See the C{MSG_}
        constants in the sendmsg(2) manual page.  By default no flags are set.
    @type flags: C{int}

    @return: The return value of the underlying syscall, if it succeeds.
    """
    return socket.sendmsg([data], ancillary, flags)