The following is a simple code chunk that should explain how to use the TrystController class. @interface TrystControllerDelegate : NSObject { @private IBOutlet NSWindow *window; // the application window IBOutlet NSTableView *tableView; // table that displays found services // This table could then be used to // double click a service to // initiate a connection ... TrystController *controller; NSFileHandle *listeningSocket; NSArray *foundServices; } ... @end @implementation TrystControllerDelegate ... - (void) awakeFromNib { static BOOL beenHere = NO; NSSocketNativeHandle socket; NSNotificationCenter *nc = nil; // I've noticed that -awakeFromNib might get called several times. // Maybe I'm doing something wrong, but in any case, we want -awakeFromNib // to be called only once. if( beenHere ) return; beenHere = YES; foundServices = [[NSArray alloc] init]; controller = [[TrystController alloc] initWithName: @"some name" type: @"_foobar._tcp." port: 12345]; // Prepare the socket for possible connections socket = [[controller socket] socket]; listeningSocket = [[NSFileHandle alloc] initWithFileDescriptor: socket]; nc = [NSNotificationCenter defaultCenter]; [nc addObserver: self selector: @selector(acceptConnection:) name: NSFileHandleConnectionAcceptedNotification object: listeningSocket]; [controller setDelegate: self]; [controller activateBrowsing: YES]; // start browsing for services [controller activatePublishing: YES]; // start publishing our service // Start to listen for connections [listeningSocket acceptConnectionInBackgroundAndNotify]; [window center]; [window makeKeyAndOrderFront: self]; } ... - (void) discoveredServicesDidChange: (id) sender { [foundServices autorelease]; foundServices = [[controller discoveredServicesWithInfo] retain]; [tableView reloadData]; } - (int) numberOfRowsInTableView: (NSTableView *) tableView { return [foundServices count]; } - (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) tableColumn row: (int) row { return [[foundServices objectAtIndex: row] valueForKey: [tableColumn identifier]]; } ... @end