Function

CFNetServiceSetClient(_:_:_:)

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

Declaration

func CFNetServiceSetClient(_ theService: CFNetService, _ clientCB: CFNetServiceClientCallBack?, _ clientContext: UnsafeMutablePointer<CFNetServiceClientContext>?) -> Bool

Parameters

theService

The CFNetService; cannot be NULL.

clientCB

The callback function that is to be associated with this CFNetService. If you are shutting down the service, set clientCB to NULL to disassociate from this CFNetService the callback function that was previously associated.

clientContext

Context information to be used when clientCB is called; cannot be NULL.

Return Value

TRUE if the client was set; otherwise, FALSE.

Discussion

The callback function specified by clientCB will be called to report IP addresses (in the case of CFNetServiceResolve) or to report registration errors (in the case of CFNetServiceRegister).

Special Considerations

This function is thread safe.

For a CFNetService that will operate asynchronously, call this function and then call CFNetServiceScheduleWithRunLoop(_:_:_:) to schedule the service on a run loop. Then call CFNetServiceRegister or CFNetServiceResolve.

See Also

Network Services

class CFNetService

An opaque reference representing a CFNetService.

class CFNetServiceBrowser

An opaque reference representing a CFNetServiceBrowser.

class CFNetServiceMonitor

An opaque reference for a service monitor.

enum CFNetServiceMonitorType

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

struct CFNetServiceClientContext

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

enum CFNetServicesError

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

func CFNetServiceBrowserInvalidate(CFNetServiceBrowser)

Invalidates an instance of a Network Service browser object.

func CFNetServiceBrowserGetTypeID() -> CFTypeID

Gets the Core Foundation type identifier for the 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 CFNetServiceGetPortNumber(CFNetService) -> Int32

This function gets the port number from a CFNetService.

func CFNetServiceGetTXTData(CFNetService) -> Unmanaged<CFData>?

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

func CFNetServiceGetTypeID() -> CFTypeID

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

func CFNetServiceMonitorGetTypeID() -> CFTypeID

Gets the Core Foundation type identifier for all CFNetServiceMonitor instances.

func CFNetServiceMonitorInvalidate(CFNetServiceMonitor)

Invalidates an instance of a Network Service monitor object.

func CFNetServiceSetTXTData(CFNetService, CFData) -> Bool

Sets the TXT record for a CFNetService.