title: Bonjour DNS-SD callback not being called, where's a mistake in my code?
body: <p>I'm trying to learn how to use Bonjour using this blog article as a reference:</p>
  
  <p><a href="http://marknelson.us/2011/10/25/dns-service-discovery-on-windows/" rel="nofollow">http://marknelson.us/2011/10/25/dns-service-discovery-on-windows/</a></p>
  
  <p>I've download sample project linked at the bottom of that page, it works like charm. Now I'm trying to reproduce service discovery from scratch in my console application:</p>
  
  <pre class="lang-c prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;assert.h&gt;   
  #include "dns/dns_sd.h"
  
  class CDnsSd 
  {
  public:
      bool discoverAsync ();
  
  private:
      static void DNSSD_API onDiscoveryFinished (DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, 
                                DNSServiceErrorType errorCode, const char *serviceName, const char *regtype,
                                const char *replyDomain, void *context);
  };
  
  bool CDnsSd::discoverAsync()
  {
      DNSServiceRef client = NULL;
      const DNSServiceErrorType err = DNSServiceBrowse( &amp;client, 0, 0, ""_services._dns-sd._udp"", "", onDiscoveryFinished, this );
      return err == kDNSServiceErr_NoError;
  }
  
  void DNSSD_API CDnsSd::onDiscoveryFinished( DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *serviceName, const char *regtype, const char *replyDomain, void *context )
  {
      std::cout &lt;&lt; __FUNCTION__;
  }
  
  void main ()
  {
      CDnsSd dnsSd;
      const bool ret = dnsSd.discoverAsync();
      assert(ret);
      Sleep(10000000);
  }
  </code></pre>
  
  <p><code>DNSServiceBrowse</code> returns <code>kDNSServiceErr_NoError</code>, but the callback is never called. What's wrong?</p>