It seems endpoints of type nw_endpoint_type_bonjour_service offer no port number or TXT record. Or at least I am not smart enough to find the functions which provides these things. 😀
The functions with names most suggestive of providing these things don't work, which isn't surprising since they are documented (in the header) to work only for endpoints of other types.
This seems like a massive oversight, so I am doubting my sanity. Surely nearly everybody who wants to use nw_endpoint_type_bonjour_service wants a port number and many will want a TXT record.
I have resorted to calling DNSServiceResolve to fill the gap. It works but seems… drastic. It makes me wonder why I don't bypass nw_browser_create in favor of DNSServiceBrowse in the first place.
What am I missing?
It seems endpoints of type
nw_endpoint_type_bonjour_serviceoffer no port number or TXT record.
Right. A Bonjour endpoint describes how to connect to a service and for those you don’t need the host name, port number, or TXT record.
What am I missing?
For the host name and port number, our recommendation is that you connect to the service using a connect-to-service API. The most common case here is that you’re Network framework to connect, where you pass a Bonjour endpoint directly to nw_connection_create and it will internally resolve the service and connect.
There are two common situations where you end up needing to resolve a service:
-
When using a API that doesn’t support connect-to-service semantics, for example, BSD Sockets
-
When forming a URL to pass to, say, Safari
In that case, yeah, you have to resolve the service yourself using other APIs. I tend to do this using NSNetService [1] but it’s fine to use DNSServiceResolve.
For the TXT record, usually folks want that as part of browsing and so get that from the nw_browse_result_t, after setting nw_browse_descriptor_set_include_txt_record.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] See this post.