Function

CFNetServiceBrowserCreate

Creates an instance of a Network Service browser object.

Declaration

CFNetServiceBrowserRef CFNetServiceBrowserCreate(CFAllocatorRef alloc, CFNetServiceBrowserClientCallBack clientCB, CFNetServiceClientContext *clientContext);

Parameters

alloc

The allocator to use to allocate memory for the new object. Pass NULL or 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.

clientContext

Context information to be used when clientCB is called; cannot be NULL. For details, see CFNetServiceClientContext.

Return Value

A new browser object, or NULL if the instance could not be created. Ownership follows the The Create Rule.

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. Then call CFNetServiceBrowserSearchForDomains and 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.

If you do not call CFNetServiceBrowserScheduleWithRunLoop, searches with the resulting CFNetServiceBrowser are made in synchronous mode. Calls made to CFNetServiceBrowserSearchForDomains and 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 from another thread, or an error occurs.

To shut down a CFNetServiceBrowser that is running in asynchronous mode, call CFNetServiceBrowserStopSearch, followed by CFNetServiceBrowserUnscheduleFromRunLoop, and then CFNetServiceBrowserInvalidate.

Special Considerations

This function is thread safe.

See Also

Network Services

CFNetServiceRef

An opaque reference representing a CFNetService.

CFNetServiceBrowserRef

An opaque reference representing a CFNetServiceBrowser.

CFNetServiceMonitorRef

An opaque reference for a service monitor.

CFNetServiceMonitorType

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

CFNetServiceClientContext

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

CFNetServicesError

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

CFNetServiceBrowserInvalidate

Invalidates an instance of a Network Service browser object.

CFNetServiceBrowserScheduleWithRunLoop

Schedules a CFNetServiceBrowser on a run loop.

CFNetServiceBrowserGetTypeID

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

CFNetServiceBrowserSearchForServices

Searches a domain for services of a specified type.

CFNetServiceBrowserStopSearch

Stops a search for domains or services.

CFNetServiceBrowserUnscheduleFromRunLoop

Unschedules a CFNetServiceBrowser from a run loop and mode.

CFNetServiceCancel

Cancels a service registration or a service resolution.

CFNetServiceCreate

Creates an instance of a Network Service object.

CFNetServiceCreateCopy

Creates a copy of a CFNetService object.

CFNetServiceCreateDictionaryWithTXTData

Uses TXT record data to create a dictionary.

CFNetServiceCreateTXTDataWithDictionary

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

CFNetServiceGetAddressing

Gets the IP addressing from a CFNetService.

CFNetServiceGetDomain

Gets the domain from a CFNetService.

CFNetServiceGetName

Gets the name from a CFNetService.

CFNetServiceGetPortNumber

This function gets the port number from a CFNetService.

CFNetServiceGetTXTData

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

CFNetServiceGetTargetHost

Queries a CFNetService for its target hosts.

CFNetServiceGetType

Gets the type from a CFNetService.

CFNetServiceGetTypeID

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

CFNetServiceMonitorCreate

Creates an instance of a NetServiceMonitor object that watches for record changes.

CFNetServiceMonitorGetTypeID

Gets the Core Foundation type identifier for all CFNetServiceMonitor instances.

CFNetServiceMonitorInvalidate

Invalidates an instance of a Network Service monitor object.

CFNetServiceMonitorScheduleWithRunLoop

Schedules a CFNetServiceMonitor on a run loop.

CFNetServiceMonitorStart

Starts monitoring.

CFNetServiceMonitorStop

Stops a CFNetServiceMonitor.

CFNetServiceMonitorUnscheduleFromRunLoop

Unschedules a CFNetServiceMonitor from a run loop.

CFNetServiceRegister

Makes a CFNetService available on the network.

Deprecated
CFNetServiceRegisterWithOptions

Makes a CFNetService available on the network.

CFNetServiceResolve

This function updates the specified CFNetService with the IP address or addresses associated with the service. Call CFNetServiceGetAddressing to get the addresses.

Deprecated
CFNetServiceResolveWithTimeout

Gets the IP address or addresses for a CFNetService.

CFNetServiceSetClient

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

CFNetServiceSetTXTData

Sets the TXT record for a CFNetService.

CFNetServiceUnscheduleFromRunLoop

Unschedules a CFNetService from a run loop.

CFNetServiceScheduleWithRunLoop

Schedules a CFNetService on a run loop.