From af2937e046b1ca6f1121a424ee0adc84569eb83d Mon Sep 17 00:00:00 2001
From: "F. Duncanh" export OPENSSL_ROOT_DIR=/usr/lib/X86_64-linux-gnu/ before
running cmake.
Stalling this way, with no server name showing on the client as available, probably means that your network does -not have a running Bonjour/zeroconf DNS-SD server. On Linux, -make sure Avahi is installed, and start the avahi-daemon service on the -system running uxplay (your distribution will document how to do this). -Some systems may instead use the mdnsd daemon as an alternative to -provide DNS-SD service. (FreeBSD offers both alternatives, but only -Avahi was tested: one of the steps needed for getting Avahi running on a -FreeBSD system is to edit +not have a running Bonjour/zeroconf DNS-SD server.
+UxPlay used to stall silently if DNS-SD service registration failed, +but now stops with an error message returned by the DNSServiceRegister +function, which will probably be -65537 (0xFFFE FFFF, or +kDNSServiceErr_Unknown) if no DNS-SD server was found: mDNS error codes +are in the range FFFE FF00 (-65792) to FFFE FFFF (-65537), and are +listed in Apple’s dnssd.h file. An older version of this (the one used +by avahi) is found here. +A few additional error codes are defined in a later version from Apple.
+On Linux, make sure Avahi is installed, and start the avahi-daemon
+service on the system running uxplay (your distribution will document
+how to do this). Some systems may instead use the mdnsd daemon as an
+alternative to provide DNS-SD service. (FreeBSD offers both
+alternatives, but only Avahi was tested: one of the steps needed for
+getting Avahi running on a FreeBSD system is to edit
/usr/local/etc/avahi/avahi-daemon.conf to uncomment a line
for airplay support.)
After starting uxplay, use the utility
diff --git a/README.md b/README.md
index 4a49155..9df32cd 100644
--- a/README.md
+++ b/README.md
@@ -692,10 +692,18 @@ Solution: when more than one installation of OpenSSL is present, set the environ
on 64-bit Ubuntu, this is done by
running `export OPENSSL_ROOT_DIR=/usr/lib/X86_64-linux-gnu/` before running cmake.
-### 1. uxplay starts, but stalls after "Initialized server socket(s)" appears, *without any server name showing on the client*.
+### 1. uxplay starts, but stalls or stops after "Initialized server socket(s)" appears, *without any server name showing on the client*.
Stalling this way, with _no_ server name showing _on the client_ as available,
probably means that your network **does not have a running Bonjour/zeroconf DNS-SD server.**
+
+UxPlay used to stall silently if DNS-SD service registration failed, but now stops with an error message returned by the
+DNSServiceRegister function, which will probably be -65537 (0xFFFE FFFF, or kDNSServiceErr_Unknown) if no DNS-SD server was found:
+mDNS error codes are in the range FFFE FF00 (-65792) to FFFE FFFF (-65537), and are listed in Apple's
+dnssd.h file. An older version of this (the one used by avahi) is found [here](https://github.com/lathiat/avahi/blob/master/avahi-compat-libdns_sd/dns_sd.h).
+A few additional error codes are defined in a later version
+from [Apple](https://opensource.apple.com/source/mDNSResponder/mDNSResponder-544/mDNSShared/dns_sd.h.auto.html).
+
On Linux, make sure Avahi is installed,
and start the avahi-daemon service on the system running uxplay (your distribution will document how to do this).
Some systems may instead use the mdnsd daemon as an alternative to provide DNS-SD service.
diff --git a/README.txt b/README.txt
index ef7c68e..632519f 100644
--- a/README.txt
+++ b/README.txt
@@ -844,18 +844,31 @@ correct one; on 64-bit Ubuntu, this is done by running
`export OPENSSL_ROOT_DIR=/usr/lib/X86_64-linux-gnu/` before running
cmake.
-### 1. uxplay starts, but stalls after "Initialized server socket(s)" appears, *without any server name showing on the client*.
+### 1. uxplay starts, but stalls or stops after "Initialized server socket(s)" appears, *without any server name showing on the client*.
Stalling this way, with *no* server name showing *on the client* as
available, probably means that your network **does not have a running
-Bonjour/zeroconf DNS-SD server.** On Linux, make sure Avahi is
-installed, and start the avahi-daemon service on the system running
-uxplay (your distribution will document how to do this). Some systems
-may instead use the mdnsd daemon as an alternative to provide DNS-SD
-service. *(FreeBSD offers both alternatives, but only Avahi was tested:
-one of the steps needed for getting Avahi running on a FreeBSD system is
-to edit `/usr/local/etc/avahi/avahi-daemon.conf` to uncomment a line for
-airplay support.*)
+Bonjour/zeroconf DNS-SD server.**
+
+UxPlay used to stall silently if DNS-SD service registration failed, but
+now stops with an error message returned by the DNSServiceRegister
+function, which will probably be -65537 (0xFFFE FFFF, or
+kDNSServiceErr_Unknown) if no DNS-SD server was found: mDNS error codes
+are in the range FFFE FF00 (-65792) to FFFE FFFF (-65537), and are
+listed in Apple's dnssd.h file. An older version of this (the one used
+by avahi) is found
+[here](https://github.com/lathiat/avahi/blob/master/avahi-compat-libdns_sd/dns_sd.h).
+A few additional error codes are defined in a later version from
+[Apple](https://opensource.apple.com/source/mDNSResponder/mDNSResponder-544/mDNSShared/dns_sd.h.auto.html).
+
+On Linux, make sure Avahi is installed, and start the avahi-daemon
+service on the system running uxplay (your distribution will document
+how to do this). Some systems may instead use the mdnsd daemon as an
+alternative to provide DNS-SD service. *(FreeBSD offers both
+alternatives, but only Avahi was tested: one of the steps needed for
+getting Avahi running on a FreeBSD system is to edit
+`/usr/local/etc/avahi/avahi-daemon.conf` to uncomment a line for airplay
+support.*)
After starting uxplay, use the utility `avahi-browse -a -t` in a
different terminal window on the server to verify that the UxPlay
diff --git a/lib/dnssd.c b/lib/dnssd.c
index e6e5cbd..2a93790 100644
--- a/lib/dnssd.c
+++ b/lib/dnssd.c
@@ -255,6 +255,7 @@ int
dnssd_register_raop(dnssd_t *dnssd, unsigned short port)
{
char servname[MAX_SERVNAME];
+ DNSServiceErrorType retval;
assert(dnssd);
@@ -295,7 +296,7 @@ dnssd_register_raop(dnssd_t *dnssd, unsigned short port)
strncat(servname, dnssd->name, sizeof(servname)-strlen(servname)-1);
/* Register the service */
- dnssd->DNSServiceRegister(&dnssd->raop_service, 0, 0,
+ retval = dnssd->DNSServiceRegister(&dnssd->raop_service, 0, 0,
servname, "_raop._tcp",
NULL, NULL,
htons(port),
@@ -303,14 +304,14 @@ dnssd_register_raop(dnssd_t *dnssd, unsigned short port)
dnssd->TXTRecordGetBytesPtr(&dnssd->raop_record),
NULL, NULL);
-
- return 1;
+ return (int) retval; /* error codes are listed in Apple's dns_sd.h */
}
int
dnssd_register_airplay(dnssd_t *dnssd, unsigned short port)
{
char device_id[3 * MAX_HWADDR_LEN];
+ DNSServiceErrorType retval;
assert(dnssd);
@@ -332,7 +333,7 @@ dnssd_register_airplay(dnssd_t *dnssd, unsigned short port)
dnssd->TXTRecordSetValue(&dnssd->airplay_record, "vv", strlen(AIRPLAY_VV), AIRPLAY_VV);
/* Register the service */
- dnssd->DNSServiceRegister(&dnssd->airplay_service, 0, 0,
+ retval = dnssd->DNSServiceRegister(&dnssd->airplay_service, 0, 0,
dnssd->name, "_airplay._tcp",
NULL, NULL,
htons(port),
@@ -340,7 +341,7 @@ dnssd_register_airplay(dnssd_t *dnssd, unsigned short port)
dnssd->TXTRecordGetBytesPtr(&dnssd->airplay_record),
NULL, NULL);
- return 1;
+ return (int) retval; /* error codes are listed in Apple's dns_sd.h */
}
const char *
diff --git a/uxplay.cpp b/uxplay.cpp
index f80b098..2694286 100644
--- a/uxplay.cpp
+++ b/uxplay.cpp
@@ -1260,6 +1260,7 @@ extern "C" void log_callback (void *cls, int level, const char *msg) {
int start_raop_server (std::vector