1 <?xml version="1.0" standalone="no"?>
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"
9 <title>D-Bus FAQ</title>
10 <releaseinfo>Version 0.1</releaseinfo>
11 <date>22 January 2005</date>
14 <firstname>Havoc</firstname>
15 <surname>Pennington</surname>
17 <orgname>Red Hat, Inc.</orgname>
19 <email>hp@pobox.com</email>
24 <firstname>David</firstname>
25 <othername role="mi">A</othername>
26 <surname>Wheeler</surname>
41 This is probably best answered by reading the D-Bus <ulink url="dbus-tutorial.html">tutorial</ulink>. In
42 short, it is a system consisting of 1) a wire protocol for exposing a
43 typical object-oriented language/framework to other applications; and
44 2) a bus daemon that allows applications to find and monitor one another.
52 Is D-Bus stable/finished?
57 D-Bus has not yet reached 1.0. The <ulink url="README">README</ulink>
58 file has a discussion of the API/ABI stability guarantees before and
59 after 1.0. In short, there are no guarantees before 1.0, and stability
60 of both protocol and reference library will be maintained after 1.0.
61 As of January 2005 we don't expect major protocol or API changes prior
62 to the 1.0 release, but anything is possible.
70 How is the reference implementation licensed? Can I use it in
71 proprietary applications?
76 The short answer is yes, you can use it in proprietary applications.
77 You should read the <ulink url="COPYING">COPYING</ulink> file, which
78 offers you the choice of two licenses. These are the GPL and the
79 AFL. The GPL requires that your application be licensed under the GPL
80 as well. The AFL is an "X-style" or "BSD-style" license compatible
81 with proprietary licensing, but it does have some requirements; in
82 particular it prohibits you from filing a lawsuit alleging that the
83 D-Bus software infringes your patents <emphasis>while you continue to
84 use D-Bus</emphasis>. If you're going to sue, you have to stop using
85 the software. Read the licenses to determine their meaning, this FAQ
86 entry is not intended to change the meaning or terms of the licenses.
94 What is the difference between a bus name, and object path,
100 If you imagine a C++ program that implements a network service, then
101 the bus name is the hostname of the computer running this C++ program,
102 the object path is a C++ object instance pointer, and an interface is
103 a C++ class (a pure virtual or abstract class, to be exact).
106 In Java terms, the object path is an object reference,
107 and an interface is a Java interface.
110 People get confused because if they write an application
111 with a single object instance and a single interface,
112 then the bus name, object path, and interface look
113 redundant. For example, you might have a text editor
114 that uses the bus name <literal>org.freedesktop.TextEditor</literal>,
115 has a global singleton object called
116 <literal>/org/freedesktop/TextEditor</literal>, and
117 that singleton object could implement the interface
118 <literal>org.freedesktop.TextEditor</literal>.
121 However, a text editor application could as easily own multiple bus
122 names (for example, <literal>org.kde.KWrite</literal> in addition to
123 generic <literal>TextEditor</literal>), have multiple objects (maybe
124 <literal>/org/kde/documents/4352</literal> where the number changes
125 according to the document), and each object could implement multiple
126 interfaces, such as <literal>org.freedesktop.DBus.Introspectable</literal>,
127 <literal>org.freedesktop.BasicTextField</literal>,
128 <literal>org.kde.RichTextDocument</literal>.
134 <qandaentry id="service">
142 A service is a program that can be launched by the bus daemon
143 to provide some functionality to other programs. Services
144 are normally launched according to the bus name they will
150 <qandaentry id="components">
153 Is D-Bus a "component system"?
158 It helps to keep these concepts separate in your mind:
162 Object/component system
167 GUI control/widget embedding interfaces
172 Interprocess communication system or wire protocol
178 D-Bus is not a component system. "Component system" was originally
179 defined by COM, and was essentially a workaround for the limitations
180 of the C++ object system (adding introspection, runtime location of
181 objects, ABI guarantees, and so forth). With the C# language and CLR,
182 Microsoft added these features to the primary object system, leaving
183 COM obsolete. Similarly, Java has much less need for something like
184 COM than C++ did. Even QObject (from Qt) and GObject (from GLib) offer
185 some of the same features found in COM.
188 Component systems are not about GUI control embedding. Embedding
189 a spreadsheet in a word processor document is a matter of defining
190 some specific <emphasis>interfaces</emphasis> that objects
191 can implement. These interfaces provide methods related to
192 GUI controls. So an object implementing those interfaces
196 The word "component" just means "object with some fancy features" and
197 in modern languages all objects are effectively "components."
200 So components are fancy objects, and some objects are GUI controls.
203 A third, unrelated feature is interprocess communication or IPC.
204 D-Bus is an IPC system. Given an object (or "component" if you must),
205 you can expose the functionality of that object over an IPC system.
206 Examples of IPC systems are DCOM, CORBA, SOAP, XML-RPC, and D-Bus.
207 You can use any of these IPC systems with any object/component system,
208 though some of them are "tuned" for specific object systems.
209 You can think of an IPC system primarily as a wire protocol.
212 If you combine an IPC system with a set of GUI control interfaces,
213 then you can have an out-of-process or dynamically-loaded GUI control.
216 Another related concept is the <firstterm>plugin</firstterm> or
217 <firstterm>extension</firstterm>. Generic plugin systems such as the
218 <ulink url="http://eclipse.org">Eclipse</ulink> system are not so different
219 from component/object systems, though perhaps a "plugin" tends to be a
220 bundle of objects with a user-visible name and can be
221 downloaded/packaged as a unit.
226 <qandaentry id="speed">
229 How fast is the D-Bus reference implementation?
234 Of course it depends a bit on what you're doing.
235 <ulink url="http://lists.freedesktop.org/pipermail/dbus/2004-November/001779.html">
236 This mail</ulink> contains some benchmarking. At the time of that
237 benchmark, D-Bus one-to-one communication was about 2.5x slower than
238 simply pushing the data raw over a socket. After the recent rewrite of
239 the marshaling code, D-Bus is slower than that because a lot of
240 optimization work was lost. But it can probably be sped up again.
243 D-Bus communication with the intermediate bus daemon should be
244 (and as last profiled, was) about twice as slow as one-to-one
245 mode, because a round trip involves four socket reads/writes rather
246 than two socket reads/writes.
249 The overhead comes from a couple of places; part of it is simply
250 "abstraction penalty" (there are layers of code to support
251 multiple main loops, multiple transport types, security, etc.).
252 Probably the largest part comes from data validation
253 (because the reference implementation does not trust incoming data).
254 It would be simple to add a "no validation" mode, but probably
255 not a good idea all things considered.
258 Raw bandwidth isn't the only concern; D-Bus is designed to
259 enable asynchronous communication and avoid round trips.
260 This is frequently a more important performance issue
267 <qandaentry id="size">
270 How large is the D-Bus reference implementation?
275 A production build (with assertions, unit tests, and verbose logging
276 disabled) is on the order of a 150K shared library.
279 A much, much smaller implementation would be possible by omitting out
280 of memory handling, hardcoding a main loop (or always using blocking
281 I/O), skipping validation, and otherwise simplifying things.
286 <qandaentry id="other-ipc">
289 How does D-Bus differ from other interprocess communication
290 or networking protocols?
295 The best place to start is to read the D-Bus <ulink url="dbus-tutorial.html">tutorial</ulink>, so
296 you have a concrete idea what D-Bus actually is. If you
297 understand other protocols on a wire format level, you
298 may also want to read the D-Bus <ulink url="dbus-specification.html">specification</ulink> to see what
299 D-Bus looks like on a low level.
302 As the <ulink url="dbus-tutorial.html">tutorial</ulink> and <ulink url="dbus-specification.html">specification</ulink> both explain, D-Bus is tuned
303 for some specific use cases. Thus, it probably isn't tuned
304 for what you want to do, unless you are doing the things
305 D-Bus was designed for. Don't make the mistake of thinking
306 that any system labeled "IPC" is the same thing.
309 The D-Bus authors would not recommend using D-Bus
310 for applications where it doesn't make sense.
311 The following questions compare D-Bus to some other
312 protocols primarily to help you understand D-Bus
313 and decide whether it's appropriate; D-Bus is neither intended
314 nor claimed to be the right choice for every application.
317 It should be possible to bridge D-Bus to other IPC systems,
318 just as D-Bus can be bridged to object systems.
321 Note: the D-Bus mailing list subscribers are <emphasis>very much not
322 interested</emphasis> in debating which IPC system is the One True
323 System. So if you want to discuss that, please use another forum.
329 <qandaentry id="corba">
332 How does D-Bus differ from CORBA?
337 Start by reading <xref linkend="other-ipc"/>.
340 <ulink url="http://www.omg.org">CORBA</ulink> is designed to support
341 object-oriented IPC between objects, automatically marshalling
342 parameters as necessary. CORBA is strongly supported by the <ulink
343 url="http://www.omg.org">Open Management Group (OMG)</ulink>, which
344 produces various standards and supporting documents for CORBA and has
345 the backing of many large organizations. There are many CORBA ORBs
346 available, both proprietary ORBs and free / open source software ORBs
347 (the latter include <ulink
348 url="http://orbit-resource.sourceforge.net/">ORBit</ulink>, <ulink
349 url="http://www.mico.org/">MICO</ulink>, and <ulink
350 url="http://www.theaceorb.com/">The ACE Orb (TAO)</ulink>). Many
351 organizations continue to use CORBA ORBs for various kinds of IPC.
354 Both GNOME and KDE have used CORBA and then moved away from it. KDE
355 had more success with a system called DCOP, and GNOME layered a system
356 called Bonobo on top of CORBA. Without custom extensions, CORBA does
357 not support many of the things one wants to do in a desktop
358 environment with the GNOME/KDE architecture.
361 CORBA on the other hand has a number of features of interest for
362 enterprise and web application development, though XML systems such as
363 SOAP are the latest fad.
366 Like D-Bus, CORBA uses a fast binary protocol (IIOP). Both systems
367 work in terms of objects and methods, and have concepts such as
368 "oneway" calls. Only D-Bus has direct support for "signals" as in
369 GLib/Qt (or Java listeners, or C# delegates).
372 D-Bus hardcodes and specifies a lot of things that CORBA leaves open-ended,
373 because CORBA is more generic and D-Bus has two specific use-cases in mind.
374 This makes D-Bus a bit simpler.
377 However, unlike CORBA D-Bus does <emphasis>not</emphasis> specify the
378 API for the language bindings. Instead, "native" bindings adapted
379 specifically to the conventions of a framework such as QObject,
380 GObject, C#, Java, Python, etc. are encouraged. The libdbus reference
381 implementation is designed to be a backend for bindings of this
382 nature, rather than to be used directly. The rationale is that an IPC
383 system API should not "leak" all over a program; it should come into
384 play only just before data goes over the wire. As an aside, OMG is
385 apparently working on a simpler C++ binding for CORBA.
388 Many CORBA implementations such as ORBit are faster than the libdbus
389 reference implementation. One reason is that D-Bus considers data
390 from the other end of the connection to be untrusted and extensively
391 validates it. But generally speaking other priorities were placed
392 ahead of raw speed in the libdbus implementation. A fast D-Bus
393 implementation along the lines of ORBit should be possible, of course.
396 On a more trivial note, D-Bus involves substantially fewer acronyms
403 <qandaentry id="xmlrpcsoap">
406 How does D-Bus differ from XML-RPC and SOAP?
411 Start by reading <xref linkend="other-ipc"/>.
414 In <ulink url="http://www.w3.org/TR/SOAP/">SOAP</ulink> and <ulink
415 url="http://www.xmlrpc.com">XML-RPC</ulink>, RPC calls are transformed
416 into an XML-based format, then sent over the wire (typically using the
417 HTTP protocol), where they are processed and returned. XML-RPC is the
418 simple protocol (its spec is only a page or two), and SOAP is the
419 full-featured protocol.
422 XML-RPC and SOAP impose XML parsing overhead that is normally
423 irrelevant in the context of the Internet, but significant for
424 constant fine-grained IPC among applications in a desktop session.
427 D-Bus offers persistent connections and with the bus daemon
428 supports lifecycle tracking of other applications connected
429 to the bus. With XML-RPC and SOAP, typically each method call
430 exists in isolation and has its own HTTP connection.
435 <qandaentry id="dce">
438 How does D-Bus differ from DCE?
443 Start by reading <xref linkend="other-ipc"/>.
446 <ulink url="http://www.opengroup.org/dce/">Distributed Computing
447 Environment (DCE)</ulink> is an industry-standard vendor-neutral
448 standard that includes an IPC mechanism. <ulink
449 url="http://www.opengroup.org/comm/press/05-01-12.htm">The Open Group
450 has released an implementation as open source software</ulink>. DCE
451 is quite capable, and includes a vast amount of functionality such as
452 a distributed time service. As the name implies, DCE is intended for
453 use in a large, multi-computer distributed application. D-Bus would
454 not be well-suited for this.
460 <qandaentry id="dcom">
463 How does D-Bus differ from DCOM and COM?
468 Start by reading <xref linkend="other-ipc"/>.
471 Comparing D-Bus to COM is apples and oranges;
472 see <xref linkend="components"/>.
475 DCOM (distributed COM) is a Windows IPC system designed for use with
476 the COM object system. It's similar in some ways to DCE and CORBA.
481 <qandaentry id="internet-communications-engine">
484 How does D-Bus differ from ZeroC's Internet Communications Engine (Ice)
489 Start by reading <xref linkend="other-ipc"/>.
492 The <ulink url="http://www.zeroc.com/ice.html"> Internet
493 Communications Engine (Ice)</ulink> is a powerful IPC mechanism more
494 on the level of SOAP or CORBA than D-Bus. Ice has a "dual-license"
495 business around it; i.e. you can use it under the GPL, or pay for a
501 <qandaentry id="inter-client-exchange">
504 How does D-Bus differ from Inter-Client Exchange (ICE)?
509 <ulink url="http://www.x.org/X11R6.8.1/docs/ICE/ice.pdf">ICE</ulink>
510 was developed for the X Session Management protocol (XSMP), as part of
511 the X Window System (X11R6.1). The idea was to allow desktop sessions
512 to contain nongraphical clients in addition to X clients.
515 ICE is a binary protocol designed for desktop use, and KDE's DCOP
516 builds on ICE. ICE is substantially simpler than D-Bus (in contrast
517 to most of the other IPC systems mentioned here, which are more
518 complex). ICE doesn't really define a mapping to objects and methods
519 (DCOP adds that layer). The reference implementation of ICE (libICE)
520 is often considered to be horrible (and horribly insecure).
523 DCOP and XSMP are the only two widely-used applications of ICE,
524 and both could in principle be replaced by D-Bus. (Though whether
525 GNOME and KDE will bother is an open question.)
532 <qandaentry id="dcop">
535 How does D-Bus differ from DCOP?
540 Start by reading <xref linkend="other-ipc"/>.
543 D-Bus is intentionally pretty similar to <ulink
544 url="http://developer.kde.org/documentation/library/kdeqt/dcop.html">DCOP</ulink>,
545 and can be thought of as a "DCOP the next generation" suitable for
546 sharing between the various open source desktop projects.
549 D-Bus is a bit more complex than DCOP, though the Qt binding for D-Bus
550 should not be more complex for programmers. The additional complexity
551 of D-Bus arises from its separation of object references vs. bus names
552 vs. interfaces as distinct concepts, and its support for one-to-one
553 connections in addition to connections over the bus. The libdbus
554 reference implementation has a lot of API to support multiple bindings
555 and main loops, and performs data validation and out-of-memory handling
556 in order to support secure applications such as the systemwide bus.
559 D-Bus is probably somewhat slower than DCOP due to data validation
560 and more "layers" in the reference implementation. A comparison
561 hasn't been posted to the list though.
564 At this time, KDE has not committed to using D-Bus, but there have
565 been discussions of KDE bridging D-Bus and DCOP, or even changing
566 DCOP's implementation to use D-Bus internally (so that GNOME and KDE
567 would end up using exactly the same bus). See the KDE mailing list
568 archives for some of these discussions.
574 <qandaentry id="yet-more-ipc">
577 How does D-Bus differ from [yet more IPC mechanisms]?
582 Start by reading <xref linkend="other-ipc"/>.
585 There are countless uses of network sockets in the world. <ulink
586 url="http://www.mbus.org/">MBUS</ulink>, Sun ONC/RPC, Jabber/XMPP,
587 SIP, are some we can think of quickly.
593 <qandaentry id="which-ipc">
596 Which IPC mechanism should I use?
601 Start by reading <xref linkend="other-ipc"/>.
604 If you're writing an Internet or Intranet application, XML-RPC or SOAP
605 work for many people. These are standard, available for most
606 languages, simple to debug and easy to use.
609 If you're writing a desktop application for UNIX,
610 then D-Bus is of course our recommendation for
611 talking to other parts of the desktop session.
612 (With the caveat that you should use a stable release
613 of D-Bus; until we reach 1.0, there isn't a stable release.)
616 If you're doing something complicated such as clustering,
617 distributed swarms, peer-to-peer, or whatever then
618 the authors of this FAQ don't have expertise in these
619 areas and you should ask someone else or try a search engine.
622 Note: the D-Bus mailing list is probably not the place to
623 discuss which system is appropriate for your application,
624 though you are welcome to ask specific questions about
625 D-Bus <emphasis>after reading this FAQ, the tutorial, and
626 searching the list archives</emphasis>. The best way
627 to search the list archives is probably to use
628 an Internet engine such as Google. On Google,
629 include "site:freedesktop.org" in your search.
638 How can I submit a bug or patch?
643 The D-Bus <ulink url="http://dbus.freedesktop.org">web site</ulink>
644 has a link to the bug tracker, which is the best place to store
645 patches. You can also post them to the list, especially if you want
646 to discuss the patch or get feedback.