jens@27: // jens@27: // MYDNSService.h jens@27: // MYNetwork jens@27: // jens@27: // Created by Jens Alfke on 4/23/09. jens@27: // Copyright 2009 Jens Alfke. All rights reserved. jens@27: // jens@27: jens@27: #import jens@27: #import jens@27: jens@27: jens@27: /** Abstract superclass for services based on DNSServiceRefs, such as MYPortMapper. */ jens@27: @interface MYDNSService : NSObject jens@27: { jens@27: @private jens@27: struct _DNSServiceRef_t *_serviceRef; jens@27: CFSocketRef _socket; jens@27: CFRunLoopSourceRef _socketSource; jens@27: SInt32 _error; jens@27: } jens@27: jens@27: /** Starts the service. jens@27: Returns immediately; you can find out when the service actually starts (or fails to) jens@27: by observing the isOpen and error properties. jens@27: It's very unlikely that this call itself will fail (return NO). If it does, it jens@27: probably means that the mDNSResponder process isn't working. */ jens@27: - (BOOL) open; jens@27: jens@27: - (void) close; jens@27: jens@27: jens@27: @property (readonly) struct _DNSServiceRef_t* serviceRef; jens@27: jens@27: /** The error status, a DNSServiceErrorType enum; nonzero if something went wrong. jens@27: This property is KV observable. */ jens@27: @property SInt32 error; jens@27: jens@27: // PROTECTED: jens@27: jens@27: /** Subclass must implement this abstract method to create a new DNSServiceRef. jens@27: This method is called by -open. jens@27: If an error occurs, the method should set self.error and return NULL.*/ jens@27: - (struct _DNSServiceRef_t*) createServiceRef; jens@27: jens@27: - (void) stopService; jens@27: jens@27: @end