<!--
{
  "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/CFNetServiceBrowserCreate(_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "CFNetwork"
    ],
    "preciseIdentifier" : "c:@F@CFNetServiceBrowserCreate"
  },
  "title" : "CFNetServiceBrowserCreate(_:_:_:)"
}
-->

# CFNetServiceBrowserCreate(_:_:_:)

Creates an instance of a Network Service browser object.

```
func CFNetServiceBrowserCreate(_ alloc: CFAllocator?, _ clientCB: CFNetServiceBrowserClientCallBack, _ clientContext: UnsafeMutablePointer<CFNetServiceClientContext>) -> Unmanaged<CFNetServiceBrowser>
```

## Parameters

`alloc`

The allocator to use to allocate memory for the new object. Pass `NULL` or <doc://com.apple.documentation/documentation/CoreFoundation/kCFAllocatorDefault> to use the current default allocator.

`clientCB`

Callback function that is to be called when domains and services are found; cannot be `NULL`. For details, see [`CFNetServiceBrowserClientCallBack`](/documentation/CFNetwork/CFNetServiceBrowserClientCallBack).

`clientContext`

Context information to be used when `clientCB` is called; cannot be `NULL`. For details, see [`CFNetServiceClientContext`](/documentation/CFNetwork/CFNetServiceClientContext).

## Return Value

A new browser object, or `NULL` if the instance could not be created. Ownership follows the [The Create Rule](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/20001148-103029).

## Discussion

This function creates an instance of a Network Service browser object, called a CFNetServiceBrowser, that can be used to search for domains and for services.

To use the resulting CFNetServiceBrowser in asynchronous mode, call [`CFNetServiceBrowserScheduleWithRunLoop(_:_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserScheduleWithRunLoop(_:_:_:)). Then call [`CFNetServiceBrowserSearchForDomains(_:_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserSearchForDomains(_:_:_:)) and [`CFNetServiceBrowserSearchForServices(_:_:_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserSearchForServices(_:_:_:_:)) to use the CFNetServiceBrowser to search for services and domains, respectively. The callback function specified by `clientCB` is called from a run loop to pass search results to your application. The search continues until you stop the search by calling [`CFNetServiceBrowserStopSearch(_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserStopSearch(_:_:)).

If you do not call [`CFNetServiceBrowserScheduleWithRunLoop(_:_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserScheduleWithRunLoop(_:_:_:)), searches with the resulting CFNetServiceBrowser are made in synchronous mode. Calls made to [`CFNetServiceBrowserSearchForDomains(_:_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserSearchForDomains(_:_:_:)) and [`CFNetServiceBrowserSearchForServices(_:_:_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserSearchForServices(_:_:_:_:)) block until there are search results, in which case the callback function specified by `clientCB` is called, until the search is are stopped by calling [`CFNetServiceBrowserStopSearch(_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserStopSearch(_:_:)) from another thread, or an error occurs.

To shut down a CFNetServiceBrowser that is running in asynchronous mode, call [`CFNetServiceBrowserStopSearch(_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserStopSearch(_:_:)), followed by [`CFNetServiceBrowserUnscheduleFromRunLoop(_:_:_:)`](/documentation/CFNetwork/CFNetServiceBrowserUnscheduleFromRunLoop(_:_:_:)), and then [`CFNetServiceBrowserInvalidate(_:)`](/documentation/CFNetwork/CFNetServiceBrowserInvalidate(_:)).

### Special Considerations

This function is thread safe.

---

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)