SD_BUS_SET_SERVER(3)
π sd_bus_set_server(3) β Configure connection mode for a bus object π
okay bestie, welcome to the SD_BUS_SET_SERVER(3) manual page β the one all about configuring connection mode for a bus object. It's giving very βI know my way around D-Busβ energy, and we're gonna get through every single detail together. π«Ά
β¨ NAME β¨
sd_bus_set_server, sd_bus_is_server, sd_bus_get_bus_id, sd_bus_set_bus_client, sd_bus_is_bus_client, sd_bus_set_monitor, sd_bus_is_monitor β all of these are here to configure connection mode for a bus object. Periodt. π
πΈ SYNOPSIS πΈ
#include <systemd/sd-bus.h>
int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t id);
int sd_bus_is_server(sd_bus *bus);
int sd_bus_get_bus_id(sd_bus *bus, sd_id128_t *id);
int sd_bus_set_bus_client(sd_bus *bus, int b);
int sd_bus_is_bus_client(sd_bus *bus);
int sd_bus_set_monitor(sd_bus *bus, int b);
int sd_bus_is_monitor(sd_bus *bus);
π¦ DESCRIPTION π¦
Here's the vibe check on what each function is doing:
sd_bus_set_server()β configures the bus object as a server for direct D-Bus connections. Thebargument enables/disables server mode. Ifbis zero, server mode is disabled; otherwise, server mode is enabled. Configuring a bus object as a server is required to allow establishing direct connections between two peers without going via the D-Bus daemon. Theidmust contain a 128-bit integer id for the server. If clients add aguidfield to their D-Bus address string, the server id must match thisguidor the D-Bus authentication handshake will fail. If no specific id is defined for the server,sd_id128_randomize(3)can be used to generate a random id instead. πsd_bus_is_server()β returns whether server mode is enabled for the given bus object. Simple, iconic, no drama.sd_bus_get_bus_id()β stores the D-Bus server id inid. That id is either the one configured usingsd_bus_set_server()(for server bus objects) or the one received during D-Bus authentication (for client bus objects). πsd_bus_set_bus_client()β configures the bus object as a D-Bus daemon client. Thebargument enables/disables client mode. Ifbis zero, client mode is disabled and the bus object should connect directly to a D-Bus server. Otherwise, client mode is enabled and the bus object should connect to a D-Bus daemon. When connecting to an existing bus using any of the functions in thesd_bus_open(3)family of functions or any of the functions in thesd_bus_default(3)family of functions, the bus object is automatically configured as a bus client. However, when connecting to a D-Bus daemon by callingsd_bus_set_address(3)followed bysd_bus_start(3), the bus object should be manually configured as a bus client usingsd_bus_set_bus_client(). By default, a bus object is not configured as a D-Bus daemon client. lowkey important, bestie.sd_bus_is_bus_client()β returns whether client mode is enabled/disabled for the given bus object.sd_bus_set_monitor()β configures the bus object as a D-Bus monitor object. Thebargument enables/disables monitor mode. Ifbis zero, monitor mode is disabled. Ifbis non-zero, monitor mode is enabled. When monitor mode is enabled, no messages may be sent via the bus object and it may not expose any objects on the bus. To start monitoring messages, call theorg.freedesktop.DBus.Monitoring.BecomeMonitormethod of the D-Bus daemon and pass a list of matches indicating which messages to intercept. See The D-Bus specification[1] for more information. πsd_bus_is_monitor()β returns whether monitor mode is enabled/disabled for the given bus object.
π RETURN VALUE π
On success, sd_bus_set_server(), sd_bus_get_bus_id(), sd_bus_set_bus_client() and sd_bus_set_monitor() return a non-negative integer. On failure, they return a negative errno-style error code.
sd_bus_is_server(), sd_bus_is_bus_client() and sd_bus_is_monitor() return a positive integer when the server or client mode is enabled, respectively. Otherwise, they return zero.
π Errors π
Returned errors may indicate the following problems:
-ECHILDβ The bus connection has been created in a different process, library or module instance.
Added in version 246.
-EPERMβ The bus connection has already been started.
Added in version 246.
-ENOPKGβ The bus cannot be resolved.
Added in version 246.
-EINVALβ A required parameter wasNULLorbwas zero andiddid not equalSD_ID128_NULL.
Added in version 246.
-ENOTCONNβ The bus is not connected.
Added in version 246.
π NOTES π
Functions described here are available as a shared library, which can be compiled against and linked to with the libsystemd pkg-config(1) file. π«Ά
All functions listed here are thread-agnostic and only a single thread may operate on a given object at any given time. Different threads may access the same object at different times. Multiple independent objects may be used from different threads in parallel.
The code described here uses getenv(3), which is declared to be not multi-thread-safe. This means that the code calling the functions described here must not call setenv(3) from a parallel thread. It is recommended to only do calls to setenv() from an early phase of the program when no other threads have been started. fr fr, don't be messy with threads here.
π HISTORY π
sd_bus_set_server(), sd_bus_is_server(), sd_bus_get_bus_id(), sd_bus_set_bus_client(), sd_bus_is_bus_client(), sd_bus_set_monitor(), and sd_bus_is_monitor() were added in version 246. β
π SEE ALSO π
π NOTES π
- The D-Bus specification β
https://dbus.freedesktop.org/doc/dbus-specification.html#bus-messages-become-monitor
That's the whole page, bestie β footer vibes are systemd 261.3 and SD_BUS_SET_SERVER(3), and there's no date printed on this page. πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: libsystemd-dev 261.3-0ubuntu3 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms