Search code examples
androidandroid-ndkbonjourmdns

embedded bonjour mdnsresponder for android not working (error -65563; daemon not running)


Since jmDNS does not support the service browse by subtypes, I went with cross compiling the bonjour for android, and I followed the below steps.

  1. Cross compiled the mdnsresponder for android
  2. Wrote dns-sd client with jni wrapper that uses the above shared library that has 2 jni functions:
    1. One for calling the main loop
    2. Another for browsing the services
  3. I have written a java application with the wifi MulticastLock

But when I call the DNSServiceBrowse the error response I am getting is DNS service call failed -65563, "Background daemon is not running".

Generally while running on the linux we start mdns daemon.

How do I fix this problem? Any suggestions?


Solution

  • But when I call the DNSServiceBrowse the error response I am getting is DNS service call failed -65563, "Background daemon is not running".

    You can't run daemons within Android. See: Android daemon process

    In order to use the mdnsresponder in an embedded implementation, you must communicate with the mDNSCore directly. See the "How it Works" section of this ReadMe at [1].

    How do I fix this problem?

    Check out the "Note" section in mDNSEmbedded.h at [2] Basically rather than communicating through the daemon, you need to use the dnssd_clientshim.c at [3]. This allows you to "still use the preferred dns_sd.h APIs by linking in "dnssd_clientshim.c", which implements the standard "dns_sd.h" API calls, allocates any required storage using malloc(), and then calls through to the low-level malloc-free mDNSCore routines"

    Note: It appears that the dnssd_clientshim.c has some spelling errors and missing reference that will prevent compiling so you need to perform a patch when building (see [4] & [5]). It also appears you still need to include dnssd_clientlib.c when compiling or you'll get build errors with TXTRecord function references.

    [1] [2] [3] [4] [5]