---
title: "CFNetServiceBrowserSearchForServices(_:_:_:_:)"
framework: cfnetwork
role: symbol
role_heading: Function
path: "cfnetwork/cfnetservicebrowsersearchforservices(_:_:_:_:)"
---

# CFNetServiceBrowserSearchForServices(_:_:_:_:)

Searches a domain for services of a specified type.

## Declaration

```swift
func CFNetServiceBrowserSearchForServices(_ browser: CFNetServiceBrowser, _ domain: CFString, _ serviceType: CFString, _ error: UnsafeMutablePointer<CFStreamError>?) -> Bool
```

## Parameters

- `browser`: The CFNetServiceBrowser, obtained by previously calling doc://com.apple.cfnetwork/documentation/CFNetwork/CFNetServiceBrowserCreate(_:_:_:), that is to perform the search; cannot be NULL.
- `domain`: The domain to search for the service type; cannot be NULL. To get the domains that are available for searching, call doc://com.apple.cfnetwork/documentation/CFNetwork/CFNetServiceBrowserSearchForDomains(_:_:_:).
- `error`: A pointer to a doc://com.apple.documentation/documentation/CoreFoundation/CFStreamError structure, that, if an error occurs, will be set to the error and the error’s domain and passed to your callback function. Pass NULL if you don’t want to receive the error that may occur as a result of this particular call.

## Return Value

Return Value TRUE if the search was started (asynchronous mode); FALSE if another search is already in progress for this CFNetServiceBrowser or if an error occurred.

## Discussion

Discussion This function searches the specified domain for services that match the specified service type. The search continues until the search is canceled by calling CFNetServiceBrowserStopSearch(_:_:). When a match is found, the callback function specified when the CFNetServiceBrowser was created is called and passed an instance of a CFNetService representing the service that was found. In asynchronous mode, this function returns TRUE if the search was started. Otherwise, it returns FALSE. In synchronous mode, this function blocks until the search is stopped by calling CFNetServiceBrowserStopSearch(_:_:) from another thread, in which case this function returns FALSE, or until an error occurs. Special Considerations This function is thread safe. For any one CFNetServiceBrowser, only one domain search or one service search can be in progress at the same time.

## See Also

### Network Services

- [CFNetService](cfnetwork/cfnetservice.md)
- [CFNetServiceBrowser](cfnetwork/cfnetservicebrowser.md)
- [CFNetServiceBrowserFlags](cfnetwork/cfnetservicebrowserflags.md)
- [CFNetServiceMonitor](cfnetwork/cfnetservicemonitor.md)
- [CFNetServiceMonitorType](cfnetwork/cfnetservicemonitortype.md)
- [CFNetServiceClientContext](cfnetwork/cfnetserviceclientcontext.md)
- [CFNetServiceRegisterFlags](cfnetwork/cfnetserviceregisterflags.md)
- [CFNetServicesError](cfnetwork/cfnetserviceserror.md)
- [CFNetServiceBrowserInvalidate(_:)](cfnetwork/cfnetservicebrowserinvalidate(_:).md)
- [CFNetServiceBrowserScheduleWithRunLoop(_:_:_:)](cfnetwork/cfnetservicebrowserschedulewithrunloop(_:_:_:).md)
- [CFNetServiceBrowserCreate(_:_:_:)](cfnetwork/cfnetservicebrowsercreate(_:_:_:).md)
- [CFNetServiceBrowserGetTypeID()](cfnetwork/cfnetservicebrowsergettypeid().md)
- [CFNetServiceBrowserSearchForDomains(_:_:_:)](cfnetwork/cfnetservicebrowsersearchfordomains(_:_:_:).md)
- [CFNetServiceBrowserStopSearch(_:_:)](cfnetwork/cfnetservicebrowserstopsearch(_:_:).md)
- [CFNetServiceBrowserUnscheduleFromRunLoop(_:_:_:)](cfnetwork/cfnetservicebrowserunschedulefromrunloop(_:_:_:).md)
