CFNetServices

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.

Overview

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.

Topics

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.

Callbacks

typealias CFNetServiceBrowserClientCallBack

Defines a pointer to the callback function for a CFNetServiceBrowser.

typealias CFNetServiceClientCallBack

Defines a pointer to the callback function for a CFNetService.

typealias CFNetServiceMonitorClientCallBack

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

Data Types

class CFNetServiceBrowser

An opaque reference representing a CFNetServiceBrowser.

struct CFNetServiceClientContext

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

class CFNetServiceMonitor

An opaque reference for a service monitor.

class CFNetService

An opaque reference representing a CFNetService.

Constants

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.

enum CFNetServiceMonitorType

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

enum CFNetServicesError

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

See Also

Opaque Types

CFFTPStream

This document describes the CFStream functions for working with FTP connections. It is part of the CFFTP API.

CFHost

The CFHost API allows you to create instances of the CFHost object that you can use to acquire host information, including names, addresses, and reachability information.

CFHTTPAuthentication

The CFHTTPAuthentication opaque type provides an abstraction of HTTP authentication information.

CFHTTPMessage

The CFHTTPMessage opaque type represents an HTTP message.

CFNetDiagnostics

The CFNetDiagnostics opaque type allows you to diagnose network-related problems.