title: Avahi dns_sd compatibility layer fails to run Browse callback
body: <h3>Background</h3>
  
  <p>I'm working on a cross-platform Zeroconf/Bonjour/DNS-SD library for Haskell, and figured my best bet would bet would be to target the <a href="http://developer.apple.com/library/mac/#documentation/Networking/Reference/DNSServiceDiscovery_CRef/dns_sd_h/index.html" rel="noreferrer"><code>dns_sd.h</code></a> API. Under Linux, the implementation of this interface is provided by <a href="http://avahi.org/wiki/AboutAvahi" rel="noreferrer">Avahi</a>, which claims to support a subset of the Bonjour API.</p>
  
  <h3>Problem</h3>
  
  <p>As a sanity check for my library, I've written a small test program in C that just uses the bare bones of the API. It browses for any service on the network of type <code>_http._tcp</code>, prints a message as soon as it sees one, and then dies:</p>
  
  <pre><code>#include &lt;dns_sd.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  void cb(DNSServiceRef sdRef,
          DNSServiceFlags flags,
          uint32_t interfaceIndex,
          DNSServiceErrorType errorCode,
          const char *serviceName,
          const char *regtype,
          const char *replyDomain,
          void *context) {
    printf("called!\n");
  }
  
  int main() {
    DNSServiceRef sd = malloc(sizeof(DNSServiceRef));
    const char *regtype = "_http._tcp";
    DNSServiceErrorType err1 = DNSServiceBrowse(&amp;sd, 0, 0, regtype, NULL, &amp;cb, NULL);
    printf("err1=%d\n", err1);
    DNSServiceErrorType err2 = DNSServiceProcessResult(sd);
    printf("err2=%d\n", err2);
    return 0;
  }
  </code></pre>
  
  <p>On my Mac, this test program works fine in both C and the equivalent Haskell (it finds my printer; exciting!): </p>
  
  <pre><code>$ gcc test.c -o test
  $ ./test
  err1=0
  called!
  err2=0
  </code></pre>
  
  <p>But on my Linux machine, the program berates me before exiting without invoking the callback:</p>
  
  <pre><code>$ gcc test.c -o test -ldns_sd
  $ ./test
  *** WARNING *** The program 'test' uses the Apple Bonjour compatibility layer of Avahi.
  *** WARNING *** Please fix your application to use the native API of Avahi!
  *** WARNING *** For more information see &lt;http://0pointer.de/avahi-compat?s=libdns_sd&amp;e=test&gt;
  err1=0
  err2=0
  </code></pre>
  
  <h3>Questions</h3>
  
  <ol>
  <li>Is the Avahi <code>dns_sd</code> compatibility layer still a suitable target for a cross-platform binding? Or is that warning message serious enough about using the native Avahi API that I should consider retargeting?</li>
  <li>What is the state of the art for cross-platform Zeroconf in C?</li>
  </ol>