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

rony rony at wu.ac.at
Fri Jul 22 15:50:15 PDT 2011


Hi Mike,

thank you for your feedback!

On 22.07.2011 19:12, Mike Gorse wrote:
> My guess is that you're running a main loop that isn't listening for
> new connections on the DBusServer.  
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?).

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.

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.

(The language binding should be operating system independent, just
relying on the dbus reference implementation, hence not
relying/depending on glib.)

---

It is more like both the server and the client are not yet communicating
with each other, although both work on the given address. (I tried to
connect to a non-existing address, which causes - as expected - a
respective error. Therefore I conclude that the server sets up the
address correctly it listens to, such that clients can find that address
and return a connection pointer.)

Hopefully, there is just a simple step missing (but I have not found a
documentation yet that documents/explains what steps have to be
undertaken and/or what I might be missing) and hopefully someone can
give that missing information.

Regards,

---rony



> On Fri, 22 Jul 2011, rony wrote:
>
>> Starting successfully the server like this:
>>
>> DBusServer *server=dbus_server_listen(address, &err);
>>
>> ... no error indicated, hence: ...
>>
>>     dbus_server_set_new_connection_function(server,
>> new_connection_callback,    // callback function
>>                                             ccb, // *data
>>                                             (void (*)(void*))
>> RexxFreeMemory // memory free function
>>                                    );
>>
>> To connect to the server using from another session using:
>>
>>    DBusConnection *conn=dbus_connection_open_private(address, &err);
>>
>> ... no error indicated ...
>>
>>
>>
>> The problem: using the addresses "unix:path=/tmp/dbus-test" or
>> "tcp:host=localhost,port=23000,family=ipv4;" allows to run
>> dbus_server_listen() and doing a
>> dbus_connection_open_private() with no errors. [I can pass the
>> pointers to respective dbus-functions.]
>>
>> However, the registered new_connection_callback()-function gets never
>> invoked and if sending messages from the client no answers are
>> received, but rather timeouts occur.
>> Here's the signature that compiles successfully:
>>
>> void new_connection_callback (DBusServer *server, DBusConnection
>> *conn, void *data) {...}
>>
>>
>>
>> When killing the server, then a pending call to the server from the
>> client sessions stops (with a "org.freedesktop.DBus.Error.NoReply"
>> error message).
>>
>> This is running on Ubuntu 64 with dbus 1.4.0.
>>
>> What could be the reason(s) that the
>> new_connection_callback()-function does not get invoked? Are there
>> any additional steps that need to be taken in order for the client
>> to be able to successfully connect to the server and become able to
>> communicate with it?
>>
>> ---rony
>>
>>
>>
>>
>>
>>


More information about the dbus mailing list