[TAG] Help regarding D-BUS concepts needed.

Benjamin A. Okopnik ben at linuxgazette.net
Tue Mar 21 22:50:52 MSK 2006


On Mon, Mar 20, 2006 at 05:36:00PM +0000, PRASHANT BADALA wrote:
> Hi everyone,
> I'm Prashant Badala, a final year Computer Engineering
> student. I'm trying to study and program the D-BUS as
> a part of my project. Hence I was going through
> a book that says -
> ===========================================================
> The D-BUS C API
> Using D-BUS starts with including its header:
> #include <dbus/dbus.h>
> 
> The first thing you probably want to do is connect to
> an existing bus. Recall from our initial D-BUS discussion
> that D-BUS provides two buses, the session and the
> system bus. Let's connect to the system bus:
> DBusError error;
> DBusConnection *conn;
> dbus_error_init (&error);
> conn = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
> if (!conn) {
>     fprintf (stderr, "%s: %s\n",
>              err.name, err.message);
>     return 1;
> }
> 
> Connecting to the system bus is a nice first step, but we
> want to be able to send messages from a well-known address.
> Let's acquire a service:
> dbus_bus_acquire_service (conn, "org.pirate.parrot",
>                           0, &err);
> if (dbus_error_is_set (&err)) {
>     fprintf (stderr, "%s: %s\n",
>              err.name, err.message);
>     dbus_connection_disconnect (conn);
>     return;
> }
> 
> Now that we are on the system bus and have acquired
> the org.pirate.parrot service, we can send messages
> originating from that address. Let's send a signal:
> ===========================================================
> Now in this particular text I'm not quite able to understand
> the concept of a "service" and the "address". What service
> does "org.pirate.parrot" specify ? What is the meaning
> of a message originating from it's address ?

I'd say that you have to look at the code or the documentation of the
API to figure out what "dbus_bus_get" and "dbus_bus_acquire_service" do;
since these are (presumably) defined somewhere before this part of the
book, you'll need to go back and set a mental bookmark for those
functions. 

> Could you also explain what is the differnce between
> "org.pirate.parrot.attr" and "org/pirate/parrot/attr"
> when been specified indivisually in the function
> "dbus_message_new_signal".

No idea - for the same exact reason as above. It all depends on what the
function does.

> Basically I'm trying to write two programs that could
> send text to each other (over d-bus) when executed
> on the same system. For this purpose do I need to be
> connected to the 'net at the time of executing the above
> mentioned programs. (Might sound stupid... but somehow taking
> a look at the given program prompts me to ask this...). Can
> you give me some advise regarding this ?

Well, local communications usually take place via a unix(7) socket,
which certainly does not require a network connection; however, I
suspect from the content of what you've sent us that the author is using
some kind of a specialized protocol/method of sending the data. It
_shouldn't_ need anything like that - it would be like requiring someone
to drive a car as a part of moving a piece of furniture from one room to
another within a house - but anything is possible.

It all comes back to Reading The Fine Manual.


* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://linuxgazette.net *





More information about the TAG mailing list