searchForServices(ofType:inDomain:)
Starts a search for services of a particular type within a specific domain.
Declaration
func searchForServices(ofType type: String, inDomain domainString: String)Parameters
- type:
Type of the service to search for.
- domainString:
Domain name in which to perform the search.
Discussion
This method returns immediately, sending a netServiceBrowserWillSearch(_:) message to the delegate if the network was ready to initiate the search.The delegate receives subsequent netServiceBrowser(_:didFind:moreComing:) messages for each service discovered.
The serviceType argument must contain both the service type and transport layer information. To ensure that the mDNS responder searches for services, rather than hosts, make sure to prefix both the service name and transport layer name with an underscore character (”_”). For example, to search for an HTTP service on TCP, you would use the type string “_http._tcp.”. Note that the period character at the end is required.
The domainName argument can be an explicit domain name, the generic local domain @"local." (note trailing period, which indicates an absolute name), or the empty string (@""), which indicates the default registration domains. Usually, you pass in an empty string. Note that it is acceptable to use an empty string for the domainName argument when publishing or browsing a service, but do not rely on this for resolution.