Howto setup/connect to a listening server [dbus_server_liste (...)] ?

Mike Gorse mgorse at novell.com
Fri Jul 22 17:53:57 PDT 2011


On Sat, 23 Jul 2011, rony wrote:

> There is no main-loop in this case, but a callback function that should
> get invoked by the server once a connection is established (authenticated?).

Then what are you using to listen for events on your server, if not a main 
loop?  Ie, are you calling select() on a set of file descriptors?

> According to the documentation the server gets started with a call to
> dbus_server_listen() and if a connection happens the function gets
> called back that gets submitted via the
> dbus_server_set_new_connection_function()-call.

As discussed in the documentation to dbus_server_listen, 
dbus_server_set_watch_functions() and dbus_server_set_timeout_functions() 
need to be called in addition to dbus_server_set_new_connection_function.

>
> The server starts and supplies the given addresses to clients that try
> to connect to these addresses. But nothing more happens, the callback
> function on the server side is not invoked. Calls from the client get no
> answers but timeout.
>
>> If you're using glib, then there's a function in dbus-glib called
>> dbus_server_setup_with_g_main that will integrate the server into the
>> glib main loop.  Otherwise that function might be useful to look at (I
>> don't understand how watches work all that well, but they need to be
>> set).
> glib is not used at all in this case. Also there are no watch and
> timeout callbacks set up as there is no main-loop to be serviced.

If you aren't using a standard main loop, then I think you'll need to roll 
your own code to handle dbus watches and invoke their callbacks when there 
is data available; otherwise libdbus won't know that there is data to 
process on the socket.  Your binding will need to expose or wrap these 
watch functions somehow.  If you have a binding for glib, then I'd 
recommend binding the dbus_*_setup_with_g_main functions from dbus-glib as 
well, since they make it convenient to integrate a dbus server or 
connection.

Hth,
-Mike G-


More information about the dbus mailing list