[avahi] Python and browsing for services
lennart at poettering.net
Wed Aug 20 08:23:14 PDT 2008
On Wed, 20.08.08 15:39, Nathan Huesken (avahi at lonely-star.org) wrote:
> I want to write a python program which browses for avahi services, dumps them and quits.
> I can not find no more python-avahi documentation than this: http://avahi.org/wiki/PythonBrowseExample
> I wonder:
> - Is it possible to browse for services not asyncronly.
No this is not possible. Browsing for services is always an
> - If I have to browse for services asyncronly (as in the example),
> is there some way to know when I have all services?
Yes and no.
The mDNS/DNS-SD protocol doesn't really allow this. Services can come
and go all the time, you can never know if the list you assembled is
complete or not.
However, because this is sometimes useful to have we provide something
similar. Browser obejcts will signal the AVAHI_BROWSER_ALL_FOR_NOW
event, when Avahi thinks that no further response will be received any
time soon. This is implemented by just waiting long enough so that all
response delays by other hosts are known to be elapsed, with the
exception that if the specific query is already available in the cache
we return immediately. This means that depending of the state of the
cache it might take 1s or so until ALL_FOR_NOW is triggered
avahi-browse -t uses ALL_FOR_NOW to terminate when no further services
are expected to be found.
Usually however, it is more applicable to do long running queries and
provide the user with a live view on the set of services found. Or the
other way round: using ALL_FOR_NOW is often enough a sign for a broken
UI. Before you proceed hacking, please make sure that this is not the
case for what you are trying to do.
Lennart Poettering Red Hat, Inc.
lennart [at] poettering [dot] net ICQ# 11060553
http://0pointer.net/lennart/ GnuPG 0x1A015CC4
More information about the avahi