C-API Examples

Kosina, Martin martin.kosina at intel.com
Thu May 4 17:23:26 PDT 2006

Thiago wrote:
>The way I see it, the libdbus-1 C API is so low level that 
>it's hard to get right. There are many pitfalls, including services not

>listing their interface introspection correctly (think HAL, for

Yes, its been a bit overwhelming. Having written a somewhat similar IPC
system from scratch, I do recognize some of the basic patterns involved
- although you are right, at ~75 KLOC, the codebase is pretty hard to
grasp sometimes. I am unfortunately fighting the internals (due to the
Win32 porting effort) and the public interface concepts at the same
time, not an ideal situation, either.

Matt wrote:
> http://www.matthew.ath.cx/misc/dbus/ is one that I compiled when I
> worked it out while writing a simple app and the Java bindings.

Thanks - that is very helpful. I can get everything to connect/register
on the bus, but it seems that _dbus_connection_read_write_dispatch()
never does any reading (so the send/receive or listen/query pairs never
exchange anything). (It seems status is always DBUS_DISPATCH_COMPLETED
after the initial exchange, hence
_dbus_connection_do_iteration_unlocked() never gets subsequently called
?) I put a breakpoint at _dbus_read() and it never gets hit...

Has anyone tried these recently ? I suspect something might have
changed, because _dbus_connection_read_write_dispatch() doesn't even run
without some //hacking due to a call to _dbus_return_val_if_fail(),
which appears to assert that the function call does not start with an
'_' (leading me to believe its been a while since this actually worked -
but perhaps I am missing something simple ?).

Re: low-level API choice
> Can you share with us your reasons for that?

Ok, this is going to be slightly OT, but since you asked :-) We don't
want the Qt or Glib dependencies, especially on Windows. The application
is a CORBA-like distributed component system used for a very particular
purpose, by people that currently live and breathe perl - so to be
adopted, it must be VERY simple to use and set up, i.e. no special
libraries, mingw-type toolchains, etc. D-bus looked very interesting
because of the existing object registration, but perhaps we are
stretching the use-case a bit...


More information about the dbus mailing list