Debian Codegraph @

man/sd_varlink_send.xml

raw
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6 <refentry id="sd_varlink_send" xmlns:xi="http://www.w3.org/2001/XInclude">
7
8 <refentryinfo>
9 <title>sd_varlink_send</title>
10 <productname>systemd</productname>
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>sd_varlink_send</refentrytitle>
15 <manvolnum>3</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>sd_varlink_send</refname>
20 <refname>sd_varlink_sendb</refname>
21 <refname>sd_varlink_sendbo</refname>
22
23 <refpurpose>Enqueues a Varlink method call, not expecting a reply</refpurpose>
24 </refnamediv>
25
26 <refsynopsisdiv>
27 <funcsynopsis>
28 <funcsynopsisinfo>#include &lt;systemd/sd-varlink.h&gt;</funcsynopsisinfo>
29
30 <funcprototype>
31 <funcdef>int <function>sd_varlink_send</function></funcdef>
32 <paramdef>sd_varlink *<parameter>link</parameter></paramdef>
33 <paramdef>const char *<parameter>method</parameter></paramdef>
34 <paramdef>sd_json_variant *<parameter>parameters</parameter></paramdef>
35 </funcprototype>
36
37 <funcprototype>
38 <funcdef>int <function>sd_varlink_sendb</function></funcdef>
39 <paramdef>sd_varlink *<parameter>link</parameter></paramdef>
40 <paramdef>const char *<parameter>method</parameter></paramdef>
41 <paramdef>…</paramdef>
42 </funcprototype>
43
44 <funcprototype>
45 <funcdef>int <function>sd_varlink_sendbo</function></funcdef>
46 <paramdef>sd_varlink *<parameter>link</parameter></paramdef>
47 <paramdef>const char *<parameter>method</parameter></paramdef>
48 <paramdef>…</paramdef>
49 </funcprototype>
50 </funcsynopsis>
51 </refsynopsisdiv>
52
53 <refsect1>
54 <title>Description</title>
55
56 <para><function>sd_varlink_send()</function> submits a method call via a Varlink connection. It takes the
57 Varlink connection object, a method name as string parameter, and a JSON object containing the parameters
58 to pass as function parameters. This call is asynchronous: the message will not be delivered immediately
59 but only once
60 <citerefentry><refentrytitle>sd_varlink_process</refentrytitle><manvolnum>3</manvolnum></citerefentry> is
61 invoked (which will happen automatically in one of the following event loop iterations if the Varlink
62 connection is attached to an even loop).</para>
63
64 <para><function>sd_varlink_sendb()</function> is similar to <function>sd_varlink_send()</function>, but
65 instead of expecting a fully constructed <type>sd_json_variant</type> object carrying the parameters,
66 this object is constructed on-the-fly directly from the parameter list, in a style identical to
67 <citerefentry><refentrytitle>sd_json_build</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
68
69 <para><function>sd_varlink_sendbo()</function> is identical to <function>sd_varlink_sendb()</function>,
70 but an enclosing object is implicitly added, so that the parameter list is expected to consist of field
71 pairs only. For details about the expected argument list, see
72 <citerefentry><refentrytitle>sd_json_buildo</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
73
74 <para>Use <function>sd_varlink_send()</function>, <function>sd_varlink_sendb()</function> and
75 <function>sd_varlink_sendbo()</function> only if no method call results are required, as they neither
76 provide return parameters nor success/failure information. Use
77 <citerefentry><refentrytitle>sd_varlink_call</refentrytitle><manvolnum>3</manvolnum></citerefentry> (and
78 related calls) to submit a method call synchronously, returning the server's response.</para>
79 </refsect1>
80
81 <refsect1>
82 <title>Return Value</title>
83
84 <para>On success, <function>sd_varlink_send()</function>, <function>sd_varlink_sendb()</function> and
85 <function>sd_varlink_sendbo()</function> return a non-negative integer. On failure, they return a
86 negative errno-style error code.</para>
87
88 <refsect2>
89 <title>Errors</title>
90
91 <para>Returned errors may indicate the following problems:</para>
92
93 <variablelist>
94 <varlistentry>
95 <term><constant>-EINVAL</constant></term>
96
97 <listitem><para>An argument is invalid.</para></listitem>
98 </varlistentry>
99
100 <varlistentry>
101 <term><constant>-ENOMEM</constant></term>
102
103 <listitem><para>Memory allocation failed.</para></listitem>
104 </varlistentry>
105
106 <varlistentry>
107 <term><constant>-ENOTCONN</constant></term>
108
109 <listitem><para>The Varlink connection object is not connected.</para></listitem>
110 </varlistentry>
111
112 <varlistentry>
113 <term><constant>-EBUSY</constant></term>
114
115 <listitem><para>The Varlink connection object is already used for other purposes, i.e. executing a
116 method call or similar.</para></listitem>
117 </varlistentry>
118
119 <varlistentry>
120 <term><constant>-ENOBUFS</constant></term>
121
122 <listitem><para>The internal limit of queued messages for the Varlink connection has been
123 reached. This limit is set very high, and hitting it typically indicates that the Varlink
124 connection object is stalled — possibly because <function>sd_varlink_process()</function> has not
125 been called regularly enough, or because the peer is not processing any queued messages. This limit
126 is a safety precaution to ensure a stalled peer will not result in unbounded memory allocations on
127 the client side.</para></listitem>
128 </varlistentry>
129 </variablelist>
130 </refsect2>
131 </refsect1>
132
133 <xi:include href="libsystemd-pkgconfig.xml" />
134
135 <refsect1>
136 <title>History</title>
137 <para><function>sd_varlink_send()</function>, <function>sd_varlink_sendb()</function>,
138 <function>sd_varlink_sendbo()</function> were added in version 257.</para>
139 </refsect1>
140
141 <refsect1>
142 <title>See Also</title>
143
144 <para><simplelist type="inline">
145 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
146 <member><citerefentry><refentrytitle>sd-varlink</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
147 <member><citerefentry><refentrytitle>sd_varlink_call</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
148 <member><citerefentry><refentrytitle>sd_varlink_build</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
149 </simplelist></para>
150 </refsect1>
151 </refentry>