Created
June 28, 2011 06:27
-
-
Save leuchtetgruen/1050600 to your computer and use it in GitHub Desktop.
Bonjour Quickie in Objective-C - Service Announcement and discovery in just 6 lines of code.
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
// This is how you announce a service - saying i offer service _someservice._tcp. on port 4711 | |
NSNetService *nets = [[NSNetService alloc] initWithDomain:@"local." type:@"_someservice._tcp." name:@"" port:4711]; | |
[nets setDelegate:self]; | |
[nets publish]; | |
// And this is how you find a service | |
NSNetServiceBrowser *browser = [[NSNetServiceBrowser alloc] init]; | |
[browser setDelegate:self]; | |
[browser searchForServicesOfType:@"_someservice._tcp." inDomain:@"local."]; | |
// Isnt it great? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment