2020-03-20 01:52:52 +08:00
|
|
|
<?xml version='1.0'?>
|
|
|
|
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
|
|
|
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
2020-11-09 12:23:58 +08:00
|
|
|
<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
|
2020-03-20 01:52:52 +08:00
|
|
|
|
|
|
|
<refentry id="sd_bus_send"
|
|
|
|
xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
|
|
|
|
|
|
<refentryinfo>
|
|
|
|
<title>sd_bus_send</title>
|
|
|
|
<productname>systemd</productname>
|
|
|
|
</refentryinfo>
|
|
|
|
|
|
|
|
<refmeta>
|
|
|
|
<refentrytitle>sd_bus_send</refentrytitle>
|
|
|
|
<manvolnum>3</manvolnum>
|
|
|
|
</refmeta>
|
|
|
|
|
|
|
|
<refnamediv>
|
|
|
|
<refname>sd_bus_send</refname>
|
2020-04-24 02:40:30 +08:00
|
|
|
<refname>sd_bus_send_to</refname>
|
2021-02-19 07:20:10 +08:00
|
|
|
<refname>sd_bus_message_send</refname>
|
2020-03-20 01:52:52 +08:00
|
|
|
|
|
|
|
<refpurpose>Queue a D-Bus message for transfer</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
|
|
|
|
<refsynopsisdiv>
|
|
|
|
<funcsynopsis>
|
|
|
|
<funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo>
|
|
|
|
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>sd_bus_send</function></funcdef>
|
|
|
|
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
|
|
|
|
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
|
|
|
|
<paramdef>uint64_t *<parameter>cookie</parameter></paramdef>
|
|
|
|
</funcprototype>
|
2020-04-24 02:40:30 +08:00
|
|
|
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int <function>sd_bus_send_to</function></funcdef>
|
|
|
|
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
|
|
|
|
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
|
|
|
|
<paramdef>const char *<parameter>destination</parameter></paramdef>
|
|
|
|
<paramdef>uint64_t *<parameter>cookie</parameter></paramdef>
|
|
|
|
</funcprototype>
|
2021-02-19 07:20:10 +08:00
|
|
|
|
|
|
|
<funcprototype>
|
|
|
|
<funcdef>int sd_bus_message_send</funcdef>
|
|
|
|
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
|
|
|
|
</funcprototype>
|
2020-03-20 01:52:52 +08:00
|
|
|
</funcsynopsis>
|
|
|
|
</refsynopsisdiv>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
|
2020-04-24 02:40:30 +08:00
|
|
|
<para><function>sd_bus_send()</function> queues the bus message object <parameter>m</parameter> for
|
|
|
|
transfer. If <parameter>bus</parameter> is <constant>NULL</constant>, the bus that
|
|
|
|
<parameter>m</parameter> is attached to is used. <parameter>bus</parameter> only needs to be set when the
|
|
|
|
message is sent to a different bus than the one it's attached to, for example when forwarding messages.
|
|
|
|
If the output parameter <parameter>cookie</parameter> is not <constant>NULL</constant>, it is set to the
|
|
|
|
message identifier. This value can later be used to match incoming replies to their corresponding
|
|
|
|
messages. If <parameter>cookie</parameter> is set to <constant>NULL</constant> and the message is not
|
|
|
|
sealed, <function>sd_bus_send()</function> assumes the message <parameter>m</parameter> doesn't expect a
|
|
|
|
reply and adds the necessary headers to indicate this.</para>
|
2020-03-20 01:52:52 +08:00
|
|
|
|
|
|
|
<para>Note that in most scenarios, <function>sd_bus_send()</function> should not be called
|
|
|
|
directly. Instead, use higher level functions such as
|
|
|
|
<citerefentry><refentrytitle>sd_bus_call_method</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
|
|
|
|
<citerefentry><refentrytitle>sd_bus_reply_method_return</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
|
|
|
which call <function>sd_bus_send()</function> internally.</para>
|
2020-04-24 02:40:30 +08:00
|
|
|
|
|
|
|
<para><function>sd_bus_send_to()</function> is a shorthand for sending a message to a specific
|
|
|
|
destination. It's main use case is to simplify sending unicast signal messages (signals that only have a
|
|
|
|
single receiver). It's behavior is similar to calling
|
|
|
|
<citerefentry><refentrytitle>sd_bus_message_set_destination</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
|
|
|
followed by calling <function>sd_bus_send()</function>.</para>
|
2020-09-23 16:09:53 +08:00
|
|
|
|
|
|
|
<para><function>sd_bus_send()</function>/<function>sd_bus_send_to()</function> will write the message
|
|
|
|
directly to the underlying transport (e.g. kernel socket buffer) if possible. If the connection is not
|
|
|
|
set up fully yet the message is queued locally. If the transport buffers are congested any unwritten
|
|
|
|
message data is queued locally, too. If the connection has been closed or is currently being closed the
|
|
|
|
call fails.
|
|
|
|
<citerefentry><refentrytitle>sd_bus_process</refentrytitle><manvolnum>3</manvolnum></citerefentry> should
|
|
|
|
be invoked to write out any queued message data to the transport.</para>
|
2021-02-19 07:20:10 +08:00
|
|
|
|
|
|
|
<para><function>sd_bus_message_send()</function> is the same as <function>sd_bus_send()</function> but
|
2021-02-22 02:51:14 +08:00
|
|
|
without the first and last argument. <function>sd_bus_message_send(m)</function> is equivalent to
|
|
|
|
<function>sd_bus_send(sd_bus_message_get_bus(m), m, NULL)</function>.</para>
|
2020-03-20 01:52:52 +08:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Return Value</title>
|
|
|
|
|
2020-04-24 02:40:30 +08:00
|
|
|
<para>On success, these functions return a non-negative integer. On failure, they return a negative
|
|
|
|
errno-style error code.</para>
|
2020-03-20 01:52:52 +08:00
|
|
|
|
|
|
|
<refsect2 id='errors'>
|
|
|
|
<title>Errors</title>
|
|
|
|
|
|
|
|
<para>Returned errors may indicate the following problems:</para>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>-EINVAL</constant></term>
|
|
|
|
|
|
|
|
<listitem><para>The input parameter <parameter>m</parameter> is <constant>NULL</constant>.
|
2023-08-23 00:52:36 +08:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<xi:include href="version-info.xml" xpointer="v246"/></listitem>
|
2020-03-20 01:52:52 +08:00
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>-EOPNOTSUPP</constant></term>
|
|
|
|
|
|
|
|
<listitem><para>The bus connection does not support sending file descriptors.
|
2023-08-23 00:52:36 +08:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<xi:include href="version-info.xml" xpointer="v246"/></listitem>
|
2020-03-20 01:52:52 +08:00
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>-ECHILD</constant></term>
|
|
|
|
|
2020-04-24 02:40:30 +08:00
|
|
|
<listitem><para>The bus connection was allocated in a parent process and is being reused in a child
|
2023-08-23 00:52:36 +08:00
|
|
|
process after <function>fork()</function>.</para>
|
|
|
|
|
|
|
|
<xi:include href="version-info.xml" xpointer="v246"/></listitem>
|
2020-03-20 01:52:52 +08:00
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>-ENOBUFS</constant></term>
|
|
|
|
|
2023-08-23 00:52:36 +08:00
|
|
|
<listitem><para>The bus connection's write queue is full.</para>
|
|
|
|
|
|
|
|
<xi:include href="version-info.xml" xpointer="v246"/></listitem>
|
2020-03-20 01:52:52 +08:00
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>-ENOTCONN</constant></term>
|
|
|
|
|
|
|
|
<listitem><para>The input parameter <parameter>bus</parameter> is
|
2023-08-23 00:52:36 +08:00
|
|
|
<constant>NULL</constant> or the bus is not connected.</para>
|
|
|
|
|
|
|
|
<xi:include href="version-info.xml" xpointer="v246"/></listitem>
|
2020-03-20 01:52:52 +08:00
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>-ECONNRESET</constant></term>
|
|
|
|
|
|
|
|
<listitem><para>The bus connection was closed while waiting for the response.
|
2023-08-23 00:52:36 +08:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<xi:include href="version-info.xml" xpointer="v246"/></listitem>
|
2020-03-20 01:52:52 +08:00
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><constant>-ENOMEM</constant></term>
|
|
|
|
|
2023-08-23 00:52:36 +08:00
|
|
|
<listitem><para>Memory allocation failed.</para>
|
|
|
|
|
|
|
|
<xi:include href="version-info.xml" xpointer="v246"/></listitem>
|
2020-03-20 01:52:52 +08:00
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</refsect2>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<xi:include href="libsystemd-pkgconfig.xml" />
|
|
|
|
|
2023-09-04 20:46:35 +08:00
|
|
|
<refsect1>
|
|
|
|
<title>History</title>
|
|
|
|
<para><function>sd_bus_send()</function> was added in version 246.</para>
|
|
|
|
<para><function>sd_bus_send_to()</function> was added in version 246.</para>
|
|
|
|
</refsect1>
|
|
|
|
|
2020-03-20 01:52:52 +08:00
|
|
|
<refsect1>
|
|
|
|
<title>See Also</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
|
|
|
|
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
|
|
|
<citerefentry><refentrytitle>sd_bus_call_method</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
|
|
|
<citerefentry><refentrytitle>sd_bus_message_set_destination</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
2020-09-23 16:09:53 +08:00
|
|
|
<citerefentry><refentrytitle>sd_bus_reply_method_return</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
|
|
|
<citerefentry><refentrytitle>sd_bus_process</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
2020-03-20 01:52:52 +08:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
</refentry>
|