I am trying to create a peer-to-peer gdbus communication on a linux system. I used gdbus-codegen tool to generate the code which I can use to create the server. My server program instantiates an object using the generated skeleton functions and exports it via the g_dbus_interface_skeleton_export function. Here is an overview of the server function which gets invoked when the server receives a new connection:
static gboolean on_new_connection(GDBusServer *server, GDBusConnection *connection, gpointer user_data)
{
GError *error = NULL;
printf("Got a new connection!\n");
my_object = org_some_object_skeleton_new();
g_signal_connect(my_object, "handle-get-magic-number", G_CALLBACK(my_callback_function), NULL);
if(!g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(my_object), connection, "/some/path", &error))
return TRUE;
}
After compiling and starting the server, I try to contact it using the gdbus tool:
gdbus call --address=unix:path=/home/my_user_name/MySockets/some_socket --object-path=/some/path --method=org.some.object.get_magic_number
However, I get the following response:
Error connecting: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.DBus” on object at path /org/freedesktop/DBus
What is going on here? Is it actually possible to use the generated skeleton functions when creating a peer-to-peer server, or do I have to use the lower-level API calls such as g_dbus_connection_register_object?
From what I gather from your question and your comment, it seems like you're trying to do D-Bus IPC on a raw socket, without any D-Bus daemon running on that path. It unfortunately doesn't work like that, since D-Bus really needs some kind of broker running. You have a few options here:
dbus-daemon
or D-Bus Broker for implementations.