Hi there !<div><br></div><div>It seems the problem was not related to edge/level triggering. The Lua bindings now work correctly with ZeroMQ.</div><div><br></div><div>To ease avahi adoption by other users, I think a couple of things could be improved:</div>
<div><br></div><div>1. Better documentation of the AvahiPoll API. For example, I had to read the sources to understand that the void *userdata passed to AvahiWatch is *NOT* the void *userdata that I passed to avahi_client_new.</div>
<div>2. Better documentation of what the entry groups are and why they are needed.</div><div>3. A way to work with raw TXT data in avahi_entry_group_add_service and the resolution callback to avoid learning a non-documented string list API by reading strlst.c. Something like &quot;const char *txt, size_t txt_len&quot; is easy to understand and use.</div>
<div><br></div><div>On the API side, I wonder if there is a way to simply things. To compare, here are the number of lines of code for the same functionality using dns-sd on mac or avahi on linux:</div><div><br></div><div>
dns-sd (mac): 345 lines of code</div><div>avahi (linux): 569 lines of code</div><div><br></div><div>Code needed once in Lua: less then 10 lines of code<br></div><div><br></div><div>-- Registration</div><div>registration = mdns.Registration(&#39;_http._tcp&#39;, &#39;my server&#39;, 4545, {some = &#39;txt&#39;, content = 12}, function(self, service)</div>
<div>  print(&#39;Service registered with name:&#39;, <a href="http://service.name">service.name</a>)</div><div>end)</div><div><br></div><div>-- Browsing</div><div>browser = mdns.Browser(&#39;_http._tcp&#39;, function(self, service)</div>
<div>  print(service.op, <a href="http://service.name">service.name</a>)</div><div>end)</div><div><br></div><div>Dream code in C++:</div><div><br></div><div>avahi::Publish *pub = new avahi::Publish(&quot;_http._tcp&quot;, &quot;my server&quot;, 4545, txt_len, txt);</div>
<div>int fd = reg-&gt;fd();</div><div>// wait read in select</div><div>status = reg-&gt;status();</div><div>name = reg-&gt;name();</div><div>// ... etc</div><div><br></div><div>avahi::Browser *browser = new avahi::Browser(&quot;_http._tcp&quot;);</div>
<div>int fd = browser-&gt;fd();</div><div>// wait read on fd by inserting it into a select</div><div>while (!browser-&gt;empty()) {</div><div>  Service s = browser-&gt;pop();</div><div>  printf(&quot;%s &#39;%s&#39;&quot;, s.add ? &quot;+&quot; : &quot;-&quot;, <a href="http://s.name">s.name</a>);</div>
<div>}</div><div><br></div><div>Cheers,</div><div><br></div><div>Gaspard</div><div><br></div><div><br><div class="gmail_quote">On Tue, Mar 6, 2012 at 8:38 AM, Gaspard Bucher <span dir="ltr">&lt;<a href="mailto:gaspard@teti.ch">gaspard@teti.ch</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi list !<div><br></div><div>I am having a very difficult time creating an AvahiPoll API that should be used with an edge triggered event loop (zeroMQ).<br clear="all">
<div><br></div><div>I must confess that I do not understand why the Avahi API is so complicated (compared with dns-sd which is already not trivial). Why can&#39;t we simply connect to the daemon with a socket (once for each registration/browse) ? We would then only need one file descriptor per operation and either block on recv or insert the file descriptor in an event loop. This is the abstraction that dns-sd manages to provide with DNSServiceRefSockFD.</div>


<div><br></div><div>Anyway, before I start to fork and create pipes, I suspect my API to not work because of this edge vs level triggering. Is there a way to &quot;empty&quot; the content of newly created AvahiWatch and AvahiTimeout before registering the file descriptors inside the poll loop ?</div>

<div><br></div><div>Cheers,</div><div><br></div><div>                                                               Gaspard</div><br>
</div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><br><div>                                                               Gaspard</div><br>
</div>