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