Function

CFNetServiceCancel(_:)

Cancels a service registration or a service resolution.

Declaration

func CFNetServiceCancel(_ theService: CFNetService)

Parameters

theService

The CFNetService, obtained by previously calling CFNetServiceCreate(_:_:_:_:_:), for which a registration or a resolution is to be canceled.

Discussion

This function cancels service registrations, started by CFNetServiceRegister, thereby making the service unavailable. It also cancels service resolutions, started by CFNetServiceResolve.

If you are shutting down an asynchronous service, you should first call CFNetServiceUnscheduleFromRunLoop(_:_:_:) and CFNetServiceSetClient(_:_:_:) with clientCB set to NULL. Then call this function.

If you are shutting down a synchronous service, call this function from another thread.

This function also cancels service resolutions. You would want to cancel a service resolution if your callback function has received an IP address that you’ve successfully used to connect to the service. In addition, you might want to cancel a service resolution if the resolution is taking longer than a user would want to wait or if the user canceled the operation.

Special Considerations

This function is thread safe.

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 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 CFNetServiceSetClient(CFNetService, CFNetServiceClientCallBack?, UnsafeMutablePointer<CFNetServiceClientContext>?) -> Bool

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

func CFNetServiceSetTXTData(CFNetService, CFData) -> Bool

Sets the TXT record for a CFNetService.