adbus: an alternate c dbus client lib
Avery Pennarun
apenwarr at gmail.com
Mon Jun 22 10:58:58 PDT 2009
On Mon, Jun 22, 2009 at 1:44 AM, James McKaskill<jmckaskill at gmail.com> wrote:
> 2. The padding of messages seems a bit inconsistent in that message
> starts need to be padded to 8 bytes, but the message length does not.
> This means that you can't buffer up multiple messages in a single
> buffer and process them without moving each one.
I've run into this myself, but after some consideration, I think it
was the right choice. You can count on the kernel to buffer things
efficiently, and you won't know the length of your incoming message
(in order to allocate the buffer) until you read the first 16 bytes.
So on the receive side, you read 16 bytes, then allocate the rest of
the buffer and read only that many bytes, leaving it to the kernel to
buffer the rest.
On transmit it's a little different, but not that much. You could use
writev() to write a bunch of messages in one go.
The nice thing about the dbus protocol is that there's no wasted space
between messages. It might be a case of over-optimization, but it's
not that hard to deal with if you think of it the right way.
Have fun,
Avery
More information about the dbus
mailing list