0
votes

I've attempted to write a binding project for this project: https://github.com/tolo/HHServices

The Project uses the lower level C class : dns_sd.h. I dont know how to import this into my binding project.

All the classes that I need to bind are fine, with the exception of this one:

#import <Foundation/Foundation.h>
#include <dns_sd.h>                       // Note this!

@interface HHServiceSupport : NSObject {
@private
    CFRunLoopRef runLoop;
@protected
    DNSServiceRef sdRef;
}

@property (nonatomic, readonly) DNSServiceRef sdRef;

@property (nonatomic, assign) DNSServiceErrorType lastError;
@property (nonatomic, readonly) BOOL hasFailed;

- (void) doDestroy;
- (void) dnsServiceError:(DNSServiceErrorType)error;

- (void) openConnection;
- (void) closeConnection;

@end

My binding for this looks like:

[BaseType (typeof(NSObject))]
interface HHServiceSupport
{

//    @private
//        CFRunLoopRef runLoop;
//    @protected
//        DNSServiceRef sdRef;


//Do I bind the above??!


//@property (nonatomic, readonly) DNSServiceRef sdRef;
[Export("sdRef")]
DNSServiceRef SDRef { get; set; }

//@property (nonatomic, assign) DNSServiceErrorType lastError;
[Export("lastError")]
DNSServiceErrorType LastError { get; set; }

//@property (nonatomic, readonly) BOOL hasFailed;
[Export("hasFailed")]
bool HasFailed { get; set; }

 //- (void) doDestroy;
[Export("doDestroy")]
void  DoDestroy();

//- (void) dnsServiceError:(DNSServiceErrorType)error;
[Export("dnsServiceError:")]
void  DnsServiceError(DNSServiceErrorType error);

//- (void) openConnection;
[Export("openConnection")]
void  OpenConnection();

//- (void) closeConnection;
[Export("closeConnection")]
void  CloseConnection();

}

Because I dont know how to reference the c library dns_sd.h, I dont have any reference to classes such as DNSServiceRef, DNSServiceErrorType and so on and so the library wont build (saying these are unknown).

I've looked through all the documentation online regarding this, but dont find anything that refers to how to reference native c libraries.

The closest similar question I can find regarding this is: Referring to DNSSDObjects in dns_sd.h and DNSServiceResolve in MonoTouch which is unanswered.

Any assistance would be greatly appreciated.

ps: My ultimate goal is to enable peer to peer Bonjour so I can make a TCP socket connection between devices, instead of using GameKit, because that's just a disaster.

2

2 Answers

1
votes

Take a look at my answer to Referring to DNSSDObjects in dns_sd.h and DNSServiceResolve in MonoTouch. Not sure if it helps you as it's plain calling to dns_sd.

0
votes

While it's not a direct answer to my question, iOS6 now allows you publish Bonjour on p2p networks (Bluetooth), negating the need to wrap my own DNSSDObjects.

From Apple's iOS6 Release Notes:

Bonjour The NSNetService class and CFNetService APIs do not include P2P interfaces by default. To browse, register, or resolve services over P2P interfaces, an app needs to use the Bonjour DNSService*() APIs noted below. Setting the interfaceIndex parameter to kDNSServiceInterfaceIndexAny in the following APIs will not include P2P interfaces by default. To include P2P interfaces, you must now set the kDNSServiceFlagsIncludeP2P flag when using kDNSServiceInterfaceIndexAny, or set interfaceIndex to kDNSServiceInterfaceIndexP2P.