Problem using DBUS over TCP
Rajeev Kumar
rajisstillhere at gmail.com
Wed Sep 15 07:27:59 PDT 2010
Hi,
For my semester project i am using dbus for interprocess communication
between different services. Everything is working fine when all the services
are on a single host.
I am wondering if i can run my services on different host using dbus over
tcp??? I dig out this mailing list and found that some people have done this
and using that information i tried to run a server(have a function which
add two number ) and client (right now on same host but using dbus tcp)
My session-local.conf looks like this:
<busconfig>
<type>session</type>
<listen>tcp:host=localhost,port=1234</listen>
<listen>unix:tmpdir=/tmp</listen>
</busconfig>
Main part of my server :
g_type_init();
mainloop = g_main_loop_new (NULL, FALSE);
*connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
dbus_connection_set_allow_anonymous((DBusConnection*)connection,TRUE);
*bus_proxy = dbus_g_proxy_new_for_name (connection, DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
if (!dbus_g_proxy_call (bus_proxy, "RequestName", &error, G_TYPE_STRING,
service_name, G_TYPE_UINT, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER,
G_TYPE_INVALID, G_TYPE_UINT, &request_name_result, G_TYPE_INVALID)) { printf
("Failed to register %s",service_name); lose_gerror("",error); }
obj = g_object_new (SOME_TYPE_OBJECT, NULL);
dbus_g_connection_register_g_object (connection, "/project/demo/remote",
G_OBJECT (obj)); g_main_loop_run (mainloop);
Above code is working fine .
My client :
gchar * server = g_strdup_printf ("tcp:host=localhost,port=1234");
*connection = dbus_g_connection_open (server, &error);
add_object = dbus_g_proxy_new_for_name (connection,
DBUS_REMOTE_SERVICE1,
DBUS_REMOTE_OBJECT,
DBUS_REMOTE_INTERFACE1);
if (!dbus_g_proxy_call (add_object, "Add", &error,
G_TYPE_INT, a,G_TYPE_INT,b, G_TYPE_INVALID,
G_TYPE_INT, &result, G_TYPE_INVALID))
lose_gerror ("Failed to complete Addition", error);
While running client code i am getting following error:
Failed to complete Addition: Connection was disconnected before a reply was
received
I am stuck here . Is this the issue of authentication ??? or i am missing
something???
-Rajeev
PS : I am newbie in dbus, so please point out if i am doing something
stupid.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20100915/e22a7227/attachment.html>
More information about the dbus
mailing list