dbus_message_set/get_data usage

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Dec 11 10:21:39 PST 2013


On 11/12/13 14:37, Brosseau, Vincent wrote:
> Then I can “attach” any type of data to the message (via a pointer), as
> far as I understand.

This does not attach arbitrary data to the actual D-Bus message, only to
the DBusMessage C struct that represents it. For instance, language
bindings like dbus-python could use this as a way to link the C
DBusMessage to the Python dbus.lowlevel.Message.

When the sender sends a DBusMessage, it serializes it into some bytes
and pushes it into the stream. When the recipient receives those bytes,
it deserializes it and constructs a new DBusMessage, with its own
independent set of data slots. If the recipient was not written using
libdbus, it might deserialize the message into some other
representation, like a GDBusMessage, instead; the principle is the same
but the implementation is different.

If you want to send data in the D-Bus "wire protocol" to be received by
the recipient, it has to be represented in the message somehow - for
anything not represented in the header, that means "in the message's
arguments".

(Think about how/whether your interpretation could possibly work? The
pointer is only valid within the sending application's address space;
D-Bus doesn't know what your pointer points to, how to serialize it, or
whether it can even be serialized.)

Regards,
    S



More information about the dbus mailing list