1SD_BUS_SEND(3) sd_bus_send SD_BUS_SEND(3)
2
3
4
6 sd_bus_send, sd_bus_send_to, sd_bus_message_send - Queue a D-Bus
7 message for transfer
8
10 #include <systemd/sd-bus.h>
11
12 int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *cookie);
13
14 int sd_bus_send_to(sd_bus *bus, sd_bus_message *m,
15 const char *destination, uint64_t *cookie);
16
17 int sd_bus_message_send(sd_bus_message *m);
18
20 sd_bus_send() queues the bus message object m for transfer. If bus is
21 NULL, the bus that m is attached to is used. bus only needs to be set
22 when the message is sent to a different bus than the one it's attached
23 to, for example when forwarding messages. If the output parameter
24 cookie is not NULL, it is set to the message identifier. This value can
25 later be used to match incoming replies to their corresponding
26 messages. If cookie is set to NULL and the message is not sealed,
27 sd_bus_send() assumes the message m doesn't expect a reply and adds the
28 necessary headers to indicate this.
29
30 Note that in most scenarios, sd_bus_send() should not be called
31 directly. Instead, use higher level functions such as
32 sd_bus_call_method(3) and sd_bus_reply_method_return(3) which call
33 sd_bus_send() internally.
34
35 sd_bus_send_to() is a shorthand for sending a message to a specific
36 destination. It's main use case is to simplify sending unicast signal
37 messages (signals that only have a single receiver). It's behavior is
38 similar to calling sd_bus_message_set_destination(3) followed by
39 calling sd_bus_send().
40
41 sd_bus_send()/sd_bus_send_to() will write the message directly to the
42 underlying transport (e.g. kernel socket buffer) if possible. If the
43 connection is not set up fully yet the message is queued locally. If
44 the transport buffers are congested any unwritten message data is
45 queued locally, too. If the connection has been closed or is currently
46 being closed the call fails. sd_bus_process(3) should be invoked to
47 write out any queued message data to the transport.
48
49 sd_bus_message_send() is the same as sd_bus_send() but without the
50 first and last argument. sd_bus_message_send(m) is equivalent to
51 sd_bus_send(sd_bus_message_get_bus(m), m, NULL).
52
54 On success, these functions return a non-negative integer. On failure,
55 they return a negative errno-style error code.
56
57 Errors
58 Returned errors may indicate the following problems:
59
60 -EINVAL
61 The input parameter m is NULL.
62
63 -EOPNOTSUPP
64 The bus connection does not support sending file descriptors.
65
66 -ECHILD
67 The bus connection was allocated in a parent process and is being
68 reused in a child process after fork().
69
70 -ENOBUFS
71 The bus connection's write queue is full.
72
73 -ENOTCONN
74 The input parameter bus is NULL or the bus is not connected.
75
76 -ECONNRESET
77 The bus connection was closed while waiting for the response.
78
79 -ENOMEM
80 Memory allocation failed.
81
83 These APIs are implemented as a shared library, which can be compiled
84 and linked to with the libsystemd pkg-config(1) file.
85
87 systemd(1), sd-bus(3), sd_bus_call_method(3),
88 sd_bus_message_set_destination(3), sd_bus_reply_method_return(3),
89 sd_bus_process(3)
90
91
92
93systemd 249 SD_BUS_SEND(3)