Browsing Net Services

When a client needs to find a service, it multicasts a message onto the network. The published servers respond. Notice, however, that with busy servers on a busy or slow network, this might take some time. So a browser is told to start a search, and then, as responses come in, the delegate is informed.

NSNetServiceBrowser has the following method:

- (void)searchForServicesOfType:(NSString *)type 
                       inDomain:(NSString *)domainString

This method kicks off the search for services of the given type in the given domain. Once again, @"" can be supplied as the domain.

The delegate gets sent these messages:

- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser 
           didFindService:(NSNetService *)aNetService 
               moreComing:(BOOL)moreComing ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.