Skip navigation.
 
mlRe: NSNetServiceBrowser / NSNetService Hostname Lookup
FROM : Marc Krochmal
DATE : Fri Apr 22 18:44:56 2005

Hi Adam,

On Apr 21, 2005, at 8:01 PM, Adam wrote:

> I read about NSNetServiceBrowser and I wrote a small app that could 
> detect the rendezvous / bonjour iTunes sharing service on the 
> network using NSNetServiceBrowser and NSNetService with a service 
> type of _daap._tcp.
>
> NSNetService returns a struct sockaddr that has the IP address and 
> the port of the machine broadcasting the service. However, I would 
> also like to get the hostname / Computer Name of the machine 
> broadcasting this service. How could I obtain this info?


There's no easy way to retrieve the Computer Name of the service, but 
starting in Tiger, you'll be able to get the hostname after resolving 
the service by using the new NSNetService "hostName" method.  If you 
need to get the hostname in Panther, then you'll need to use 
DNSServiceResolve() located in /usr/include/dns_sd.h.

-Marc

Related mailsAuthorDate
mlNSNetServiceBrowser / NSNetService Hostname Lookup Adam Apr 22, 05:01
mlRe: NSNetServiceBrowser / NSNetService Hostname Lookup Marc Krochmal Apr 22, 18:44
mlRe: NSNetServiceBrowser / NSNetService Hostname Lookup Nicko van Someren Apr 22, 18:57
mlRe: NSNetServiceBrowser / NSNetService Hostname Lookup Marc Krochmal Apr 22, 19:02
mlRe: NSNetServiceBrowser / NSNetService Hostname Lookup Shaun Wexler Apr 22, 21:38