Re: How do I find the device's Bonjour hostname?
Re: How do I find the device's Bonjour hostname?
- Subject: Re: How do I find the device's Bonjour hostname?
- From: Daniel Jalkut <email@hidden>
- Date: Tue, 20 Dec 2016 15:52:30 -0500
> On Dec 20, 2016, at 2:11 PM, Jens Alfke <email@hidden> wrote:
>
> It looks as though this just returns the first component of the name, which needs to have “.local” appended; is this correct?
>
Hi Jens - this may be pertinent to your interests:
https://developer.apple.com/library/content/qa/qa1228/_index.html
It suggests against using SCDynamicStoreCopyLocalHostName to create a Bonjour hostname. I’m not sure if there is any practical scenario where assuming SCDynamicStoreCopyLocalHostName would not be the same as the Bonjour hostname, would be true.
I wonder if Quinn might have an up-to-date opinion on the validity of that advice. Taking it literally, I would think that the most reliable way to tell the “Bonjour name” for a device would be to register an NSNetService with @“” for the name, and then query it upon resolution:
{
...
_service = [[NSNetService alloc] initWithDomain:@""// 1
type:@"_music._tcp"
name:@""
port:0];
[_service setDelegate:self];
[_service publish];
}
Then in a delegate callback:
- (void)netServiceDidPublish:(NSNetService *)sender
{
NSLog(@"Got computer name %@", [sender name]);
}
Daniel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden