<!--
{
  "availability" : [
    "iOS: 2.0.0 - 27.0.0",
    "iPadOS: 2.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 10.2.0 - 27.0.0",
    "tvOS: 9.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "CFNetwork",
  "identifier" : "/documentation/CFNetwork/CFNetServiceBrowserStopSearch(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "CFNetwork"
    ],
    "preciseIdentifier" : "c:@F@CFNetServiceBrowserStopSearch"
  },
  "title" : "CFNetServiceBrowserStopSearch(_:_:)"
}
-->

# CFNetServiceBrowserStopSearch(_:_:)

Stops a search for domains or services.

```
func CFNetServiceBrowserStopSearch(_ browser: CFNetServiceBrowser, _ error: UnsafeMutablePointer<CFStreamError>?)
```

## Parameters

`browser`

The CFNetServiceBrowser that was used to start the search; cannot be `NULL`.

`error`

A pointer to a <doc://com.apple.documentation/documentation/CoreFoundation/CFStreamError> structure that will be passed to the callback function associated with this CFNetServiceBrowser (if the search is being conducted in asynchronous mode) or that is pointed to by the `error` parameter when [`CFNetServiceBrowserSearchForDomains(_:_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserSearchForDomains(_:_:_:)) or [`CFNetServiceBrowserSearchForServices(_:_:_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserSearchForServices(_:_:_:_:)) returns (if the search is being conducted in synchronous mode). Set the `domain` field to `kCFStreamErrorDomainCustom` and the `error` field to an appropriate value.

## Discussion

This functions stops a search started by a previous call to [`CFNetServiceBrowserSearchForDomains(_:_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserSearchForDomains(_:_:_:)) or [`CFNetServiceBrowserSearchForServices(_:_:_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserSearchForServices(_:_:_:_:)). For asynchronous and synchronous searches, calling this function causes the callback function associated with the CFNetServiceBrowser to be called once for each domain or service found. If the search is asynchronous, `error` is passed to the callback function. If the search is synchronous, calling this function causes [`CFNetServiceBrowserSearchForDomains(_:_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserSearchForDomains(_:_:_:)) or [`CFNetServiceBrowserSearchForServices(_:_:_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserSearchForServices(_:_:_:_:)) to return `FALSE`. If the `error` parameter for either call pointed to a <doc://com.apple.documentation/documentation/CoreFoundation/CFStreamError> structure, the <doc://com.apple.documentation/documentation/CoreFoundation/CFStreamError> structure contains the error code and the error code’s domain as set when this function was called.

### Special Considerations

This function is thread safe.

If you are stopping an asynchronous search, before calling this function, call [`CFNetServiceBrowserUnscheduleFromRunLoop(_:_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserUnscheduleFromRunLoop(_:_:_:)), followed by [`CFNetServiceBrowserInvalidate(_:)`](/documentation/CFNetwork/CFNetServiceBrowserInvalidate(_:)).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)