The CFNetServices API is part of Bonjour, Apple’s implementation of zero-configuration networking (ZEROCONF). The CFNetServices API allows you to register a network service, such as a printer or file server, so that it can be found by name or browsed for by service type and domain. Applications can use the CFNetServices API to discover the services that are available on the network and to find all access information — such as name, IP address, and port number — needed to use each service.


In effect, Bonjour registration and discovery combine the functions of a local DNS server and AppleTalk, allowing applications to provide the kind of user-friendly browsing available in the AppleTalk Chooser using open protocols, such as Multicast DNS (mDNS). Bonjour gives applications easy access to services over local IP networks without requiring the service to support an AppleTalk stack, and without requiring a DNS server on the local network.

For a full description of Bonjour, see Bonjour Overview.


CFNetServices Functions

func CFNetServiceBrowserInvalidate(CFNetServiceBrowser)

Invalidates an instance of a Network Service browser object.

func CFNetServiceBrowserUnscheduleFromRunLoop(CFNetServiceBrowser, CFRunLoop, CFString)

Unschedules a CFNetServiceBrowser from a run loop and mode.

func CFNetServiceCancel(CFNetService)

Cancels a service registration or a service resolution.

func CFNetServiceCreateDictionaryWithTXTData(CFAllocator?, CFData)

Uses TXT record data to create a dictionary.

func CFNetServiceCreateTXTDataWithDictionary(CFAllocator?, CFDictionary)

Flattens a set of key/value pairs into a CFDataRef suitable for passing to CFNetServiceSetTXTData(_:_:).

func CFNetServiceGetAddressing(CFNetService)

Gets the IP addressing from a CFNetService.

func CFNetServiceGetTargetHost(CFNetService)

Queries a CFNetService for its target hosts.

func CFNetServiceGetDomain(CFNetService)

Gets the domain from a CFNetService.

func CFNetServiceGetName(CFNetService)

Gets the name from a CFNetService.

func CFNetServiceGetPortNumber(CFNetService)

This function gets the port number from a CFNetService.

func CFNetServiceGetTXTData(CFNetService)

Queries a network service for the contents of its TXT records.

func CFNetServiceGetType(CFNetService)

Gets the type from a CFNetService.

func CFNetServiceMonitorInvalidate(CFNetServiceMonitor)

Invalidates an instance of a Network Service monitor object.

func CFNetServiceSetClient(CFNetService, CFNetServiceClientCallBack?, UnsafeMutablePointer<CFNetServiceClientContext>?)

Associates a callback function with a CFNetService or disassociates a callback function from a CFNetService.

func CFNetServiceSetTXTData(CFNetService, CFData)

Sets the TXT record for a CFNetService.

Getting the net service type IDs

func CFNetServiceGetTypeID()

Gets the Core Foundation type identifier for the Network Service object.

func CFNetServiceMonitorGetTypeID()

Gets the Core Foundation type identifier for all CFNetServiceMonitor instances.

func CFNetServiceBrowserGetTypeID()

Gets the Core Foundation type identifier for the Network Service browser object.



Defines a pointer to the callback function for a CFNetServiceBrowser.


Defines a pointer to the callback function for a CFNetService.


Defines a pointer to the callback function that is to be called when a monitored record type changes.

Data Types


An opaque reference representing a CFNetServiceBrowser.


A structure provided when a CFNetService is associated with a callback function or when a CFNetServiceBrowser is created.


An opaque reference for a service monitor.


An opaque reference representing a CFNetService.


CFNetService Registration Options

Bit flags used when registering a service.

CFNetServiceBrowserClientCallBack Bit Flags

Bit flags providing additional information about the result returned when a client’s CFNetServiceBrowserClientCallBack function is called.


Record type specifier used to tell a service monitor the type of record changes to watch for.


Error codes that may be returned by CFNetServices functions or passed to CFNetServices callback functions.

Error Domains

Error domains.