[avahi] How to handle watch events

Lennart Poettering lennart at poettering.net
Sun Aug 17 14:41:48 PDT 2008

On Thu, 07.08.08 14:54, Nathan Huesken (avahi at lonely-star.org) wrote:

> Hello,
> I have a question regarding AvahiWatch.
> - Is it possible to free all AvahiWatch in a AvahiPoll wihtout
> knowing them?

If you destroy the AvahiPoll object all watches should go away
automatically too.

> - How do I call watch_new and watch_free? Like this:
> AvahiWatch w=avahi_poll->watch_new(avahi_poll, ...);
> avahi_poll->watch_free(w)
> Is that correct?


> - If I want to watch a socket for reading, writing error and closed connection, do I have to add 4 watch events like:
> AvahiWatch read=avahi_poll->watch_new(avahi_poll, AVAHI_WATCH_IN, ...)
> AvahiWatch write=avahi_poll->watch_new(avahi_poll, AVAHI_WATCH_OUT, ...)
> AvahiWatch error=avahi_poll->watch_new(avahi_poll, AVAHI_WATCH_ERROR, ...)
> AvahiWatch close=avahi_poll->watch_new(avahi_poll, AVAHI_WATCH_HUB, ...)

No, the idea is to create only a single watch by OR'ing the flags
together: AVAHI_WATCH_IN|AVAHI_WATCH_OUT or similar.


Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net         ICQ# 11060553
http://0pointer.net/lennart/           GnuPG 0x1A015CC4

More information about the avahi mailing list