[avahi] Re: sync/async lookups

Lennart Poettering lennart at poettering.de
Sat Aug 27 23:13:07 EST 2005

On Sat, 27.08.05 05:27, Trent Lloyd (lathiat at bur.st) wrote:

> Erkkk,
> ok seems i'm confused..
> i don't quite understand the difference between ResolveHostname and
> HostnameResolver, it seems both go off into the background and send
> back a dbus reply when ready which is made to a callback so I don't
> really see the difference, could you explain?

Yes. I can.

ResolverHostName() is a DBUS method. Calling a DBUS method involves
exactly two messages sent over the bus: the method call itself in one
direction and a reply being either a failure indication or some useful
reply data in the other direction. This is perfect for "one-shot"
resolving. However, if the user wants to be notified whenever the
A/AAAA data changes a simple method call doesn't suffice, since this
might involve more then two DBUS messages: on each record change
a new notification signal needs to be sent over the BUS.

The semantics of HostNameResolver are therefore slightly different
from ResolveHostName. The former issues a "Found" signal when the
service is resolved for the first time and additional ones when the
data changes. A "Timeout" signal is issued when the initial resolution
failed or when the service is eventually removed from the network.

Both ways require some traffic to be sent over the network and waiting
for a reply. Therefore avahi-client 0.1 issued the method call
asynchronously. This makes it easy to switch internally to the new
HostNameResolver stuff. 

Initially I implemented this new interface for service resolving only:
sebest wanted to be notified of TXT record changes. However to cleanup
things a little and to make host name/address resolving as
straight-forward as possible I implemented this for hostname/address
resolving, too.

I hope this explains this a little.


Lennart Poettering; lennart [at] poettering [dot] de
ICQ# 11060553; GPG 0x1A015CC4; http://0pointer.de/lennart/

More information about the avahi mailing list