DBUS hello world service

John (J5) Palmieri johnp at redhat.com
Thu Mar 16 11:16:31 PST 2006


On Wed, 2006-03-15 at 16:37 -0600, Rohit Chaudhri wrote:
> Hi,
> I want to use DBUS as the IPC mechanism for my applications running on
> an embedded linux device. I can't use the DBUS Glib or Qt bindings so
> the implementation will use the DBUS low-level API. Since the
> communication will be point-to-point, I don't need to route the
> messages through the bus daemon so the service & clients will talk to
> each other directly
> I'm trying to learn the DBUS API, I've read the DBUS tutorial & spec
> and have written a hello-world DBUS service and client using the 0.60
> API. The code doesn't do much yet, the service calls the following
> functions and goes into a loop:
> dbus_server_listen(DBUS_HELLO_SVC,&error);
> dbus_server_set_new_connection_function(srv,onConnect,NULL,freeFunction);	dbus_server_set_watch_functions(srv,onWatchAdd,onWatchRemove,onWatchToggled,NULL,freeFunction);
> 
> On the client I call dbus_connection_open(DBUS_HELLO_SVC,&error), the
> call succeeds however the onConnect function defined in the service
> never gets called.
> I'm attaching my service/client src files with this email.
> Any idea why the onConnect method is not being called in the service?
> I've probably not done something correctly or have not initialized the
> service completely. Would appreciate any help regarding this.


You don't have a mainloop.  At the end of your service main you have
while (1) {}.  You need to have some sort of mainloop that polls,
processes and dispatches.  This is usually done by say the glib
mainloop.  You commented out the dbus mainloop.  It is a limited
mainloop that is not exported in the API.  The idea is to take that code
and integrate it into the mainloop you would be using or if you want to
make a pure server that only has to respond to dbus calls you can take
the mainloop wholesale and just copy and renamespace the API.

-- 
John (J5) Palmieri <johnp at redhat.com>



More information about the dbus mailing list