CFNetServiceMonitorCreate(_:_:_:_:)
Creates an instance of a NetServiceMonitor object that watches for record changes.
Declaration
func CFNetServiceMonitorCreate(_ alloc: CFAllocator?, _ theService: CFNetService, _ clientCB: CFNetServiceMonitorClientCallBack, _ clientContext: UnsafeMutablePointer<CFNetServiceClientContext>) -> Unmanaged<CFNetServiceMonitor>Parameters
- alloc:
The allocator to use to allocate memory for the new object. Pass
NULLor Kcfallocatordefault to use the current default allocator. - theService:
CFNetService to be monitored.
- clientCB:
Pointer to callback function that is to be called when a record associated with
theServicechanges; cannot beNULL. - clientContext:
Pointer to user-defined contextual information that is to be passed to the callback specified by
clientCBwhen the callback is called; cannot beNULL. For details, see Cfnetserviceclientcontext.
Return Value
A new instance of a CFNetServiceMonitor, or NULL if the monitor could not be created. Ownership follows the The Create Rule.
Discussion
This function creates a CFNetServiceMonitor that watches for changes in records associated with theService.
If the CFNetServiceMonitor is to run in asynchronous mode, call CFNetServiceMonitorScheduleWithRunLoop(_:_:_:) to schedule the monitor on a run loop. Then call CFNetServiceMonitorStart(_:_:_:) to start monitoring. When a change occurs, the callback function specified by clientCB will be called. For details, see CFNetServiceMonitorClientCallBack.
If the CFNetServiceMonitor is to run in synchronous mode, call CFNetServiceMonitorStart(_:_:_:).
To stop a monitor that is running in asynchronous mode, call CFNetServiceMonitorStop(_:_:) and CFNetServiceMonitorUnscheduleFromRunLoop(_:_:_:).
To stop a monitor that is running in synchronous mode, call CFNetServiceMonitorStop(_:_:).
If you no longer need to monitor record changes, call CFNetServiceMonitorStop(_:_:) to stop the monitor and then call CFNetServiceMonitorInvalidate(_:)to invalidate the monitor so it cannot be used again. Then call CFRelease to release the memory associated with CFNetServiceMonitorRef.
Special Considerations
This function is thread safe.
See Also
Network Services
CFNetServiceCFNetServiceBrowserCFNetServiceBrowserFlagsCFNetServiceMonitorCFNetServiceMonitorTypeCFNetServiceClientContextCFNetServiceRegisterFlagsCFNetServicesErrorCFNetServiceBrowserInvalidate(_:)CFNetServiceBrowserScheduleWithRunLoop(_:_:_:)CFNetServiceBrowserCreate(_:_:_:)CFNetServiceBrowserGetTypeID()CFNetServiceBrowserSearchForDomains(_:_:_:)CFNetServiceBrowserSearchForServices(_:_:_:_:)CFNetServiceBrowserStopSearch(_:_:)