PortMapper/MYDNSService.h
author Jens Alfke <jens@mooseyard.com>
Fri Apr 24 10:10:32 2009 -0700 (2009-04-24)
changeset 27 92581f26073e
child 28 732576fa8a0d
permissions -rw-r--r--
* Refactored MYPortMapper to use a new abstract base class MYDNSService; that way I can re-use it later for implementing Bonjour.
* Fixed issue #1: a memory leak in BLIPProperties, reported by codechemist.
     1 //
     2 //  MYDNSService.h
     3 //  MYNetwork
     4 //
     5 //  Created by Jens Alfke on 4/23/09.
     6 //  Copyright 2009 Jens Alfke. All rights reserved.
     7 //
     8 
     9 #import <Foundation/Foundation.h>
    10 #import <CoreFoundation/CFSocket.h>
    11 
    12 
    13 /** Abstract superclass for services based on DNSServiceRefs, such as MYPortMapper. */
    14 @interface MYDNSService : NSObject
    15 {
    16     @private
    17     struct _DNSServiceRef_t *_serviceRef;
    18     CFSocketRef _socket;
    19     CFRunLoopSourceRef _socketSource;
    20     SInt32 _error;
    21 }
    22 
    23 /** Starts the service.
    24     Returns immediately; you can find out when the service actually starts (or fails to)
    25     by observing the isOpen and error properties.
    26     It's very unlikely that this call itself will fail (return NO). If it does, it
    27     probably means that the mDNSResponder process isn't working. */
    28 - (BOOL) open;
    29 
    30 - (void) close;
    31 
    32 
    33 @property (readonly) struct _DNSServiceRef_t* serviceRef;
    34 
    35 /** The error status, a DNSServiceErrorType enum; nonzero if something went wrong. 
    36     This property is KV observable. */
    37 @property SInt32 error;
    38 
    39 // PROTECTED:
    40 
    41 /** Subclass must implement this abstract method to create a new DNSServiceRef.
    42     This method is called by -open.
    43     If an error occurs, the method should set self.error and return NULL.*/
    44 - (struct _DNSServiceRef_t*) createServiceRef;
    45 
    46 - (void) stopService;
    47 
    48 @end