GDBusConnection

The gio.dbus_connection.DBusConnection type is used for D-Bus connections to remote peers such as a message buses.

It is a low-level API that offers a lot of flexibility. For instance, it lets you establish a connection over any transport that can by represented as a gio.iostream.IOStream.

This class is rarely used directly in D-Bus clients. If you are writing a D-Bus client, it is often easier to use the func@Gio.bus_own_name, func@Gio.bus_watch_name or gio.dbus_proxy.DBusProxy.newForBus APIs.

As an exception to the usual GLib rule that a particular object must not be used by two threads at the same time, gio.dbus_connection.DBusConnections methods may be called from any thread. This is so that func@Gio.bus_get and func@Gio.bus_get_sync can safely return the same gio.dbus_connection.DBusConnection when called from any thread.

Most of the ways to obtain a gio.dbus_connection.DBusConnection automatically initialize it (i.e. connect to D-Bus): for instance, gio.dbus_connection.DBusConnection.new_ and func@Gio.bus_get, and the synchronous versions of those methods, give you an initialized connection. Language bindings for GIO should use gio.initable.Initable.new_ or gio.async_initable.AsyncInitable.newAsync, which also initialize the connection.

If you construct an uninitialized gio.dbus_connection.DBusConnection, such as via gobject.object.ObjectG.new_, you must initialize it via gio.initable.Initable.init_ or gio.async_initable.AsyncInitable.initAsync before using its methods or properties. Calling methods or accessing properties on a gio.dbus_connection.DBusConnection that has not completed initialization successfully is considered to be invalid, and leads to undefined behaviour. In particular, if initialization fails with a glib.error.ErrorG, the only valid thing you can do with that gio.dbus_connection.DBusConnection is to free it with gobject.object.ObjectG.unref.

An example D-Bus server

Here is an example for a D-Bus server: gdbus-example-server.c

An example for exporting a subtree

Here is an example for exporting a subtree: gdbus-example-subtree.c

An example for file descriptor passing

Here is an example for passing UNIX file descriptors: gdbus-unix-fd-client.c

An example for exporting a GObject

Here is an example for exporting a #GObject: gdbus-example-export.c

struct GDBusConnection