Created
March 18, 2012 18:18
-
-
Save mikebluestein/2079186 to your computer and use it in GitHub Desktop.
Add a TXTRecord using Bonjour and MonoTouch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NetDelegate _netDel; | |
NSNetService _ns; | |
void InitNetService () | |
{ | |
_ns = new NSNetService ("", "_testservice._tcp", UIDevice.CurrentDevice.Name, 9999); | |
_netDel = new NetDelegate (); | |
_ns.Delegate = _netDel; | |
// add TXTRecordData | |
var s = new NSString ("Bonjour from MonoTouch"); | |
var dictionary = NSDictionary.FromObjectAndKey (s, new NSString ("myKey")); | |
var record = NSNetService.DataFromTxtRecord (dictionary); | |
_ns.TxtRecordData = record; | |
_ns.Publish (); | |
} | |
// Run this command in Terminal to see if it was added ok: | |
// dns-sd -Z _testservice._tcp local |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment