TweetFollow Us on Twitter

Using Rendezvous

Volume Number: 19 (2003)
Issue Number: 7
Column Tag: Cocoa

Using Rendezvous

How to discover and publish services on the LAN

by Wolfgang Ante

What is Rendezvous?

To start with a buzzword: Rendezvous is zero-config networking. That means using Rendezvous you should not have to set up any server addresses, user names, and such to access and use services on the local network. Just use them. Apple users not switching over from Windows recently already know this: AppleTalk supported zero-config networking from the beginning. So why is Rendezvous better?

First, Rendezvous is based on IP networking. IP is the industry standard, the Internet protocol, and has far less overhead than most other protocols. On the other hand AppleTalk is a proprietary protocol with a lot of overhead, making it more expensive and slower.

Second, Rendezvous is open. The source code is available for download and you may include it into your software for free. You will not need this as long as your program is running on Mac OS X only. But for developers on Linux and Windows this means they can use Rendezvous, too. If you take a look at the Rendezvous mailing list you can easily see that they do.

Publishing and browsing services

When your applications wants to provide a service on the network you will have to publish it, when you want to use a service published by someone else you will have to browse for services. A service is whatever you want it to be. Rendezvous is just helping to announce and find services. It gives you all you need to connect, namely the IP address and port number, but doesn't setup the connection itself.

Cocoa gives you a very powerful way to connect to other Cocoa applications on the network called Distributed Objects. My next article will be on Distributed Objects, but for now let's get into the details of using Rendezvous in code.

Goals

I noticed that Rendezvous is not widely adopted yet, and after working with it myself I think I know why: You still have to care about a lot of things you are not very much interested in, even in Cocoa. Don't get me wrong, I think the Cocoa API to Rendezvous is very good, but for 90% of the applications that could use Rendezvous it would be very handy to have something that gives you just two things: The ability to publish a service and to browse for others who published the same type of service in one easy to use class.

This article will show you how Rendezvous works and additionally will give you a simplified interface (the ARendezvousController class) that you are free to use in your software. Using Rendezvous will open your application for teamwork. Think about it, in a lot of applications it makes sense to connect and communicate!

Overview

Cocoa gives you two classes for the two main objectives: NSNetService to publish services and NSNetServiceBrowser to browse published services.

Because network operations may take some time to finish, both classes use the concept of delegation to keep your application responsive. You ask for what you want and continue. As soon as the information is available your delegate will be notified about the found information. This also solves the problem of dynamic changes, when services are published or removed later on. Every time the situation changes your delegate will be notified.

There are quite a lot of delegation methods that make understanding the API confusing at first. I will try to concentrate on a typical flow of information, if you are interested in the complete list of delegation methods later, I recommend using the freeware "AppKiDo" from Andy Lee. It is a very good Cocoa API browser, I could not live without it anymore. It is available at <http://homepage.mac.com/aglee/downloads>.

Publishing

Publishing a service is quite easy. You create a service by creating an object of type NSNetService, set the delegate and publish the service. Listing 1 shows this:

Listing 1:

Publishing

NSNetService  *service;
NSString      *publishedName;
Int           portNumber;

service = [[NSNetService alloc] initWithDomain:@""
  type:@"_servicetype._tcp."
  name:publishedName
  port:portNumber];
[service setDelegate:delegate];
[service publish];

To publish on the default domain (which is the 'local' domain, i.e. your LAN) you pass an empty string to initWithDomain. type is an identifier for the kind of service you are publishing. The naming convention for this is "_servicetype._tcp." where you replace servicetype with your identifier. The type is usually not visible to the user, so be as clear or obscure as you like. name identifies your service to the network and must be unique. The name usually is visible to the user. Finally port must contain a port number you already acquired for the service.

setDelegate sets the delegate, this is the object that will be notified later. publish will start the process. As soon as you publish your service it will broadcast its presence on the network.

The only interesting delegate method at this point is netService:didNotPublish:. This will be sent to your delegate when the service could not be published, otherwise you can assume that your service has been published and is visible to others now.

Browsing

Browsing for services is a bit more complicated. You start by creating an object of type NSNetServiceBrowser, set the delegate and start browsing. Listing 2 shows this:

Listing 2:

Start browsing

NSNetServiceBrowser *browser;

browser = [[NSNetServiceBrowser alloc] init];
[browser setDelegate:self];
[browser searchForServicesOfType:@"_servicetype._tcp."
  inDomain:@""];

First you create the object and set the delegate to be notified, then you start browsing by asking for services of the type you are interested in. As before pass an empty string to browse in the default domain.

Again the requested information will be sent to your delegate later. The interesting ones that will be sent to you at this point are netServiceBrowser:didFindService:moreComing: and netServiceBrowser:didRemoveService:moreComing:. Rendezvous is dynamic, so services will show up and go away from time to time. As long as you do not stop browsing, your delegate will receive these messages every time something changes about the availability of services of the requested type on the network.

Lets start by looking at netServiceBrowser:didFindService:moreComing:. Listing 3 shows an implementation:

Listing 3:

Service found

- (void)netServiceBrowser:
  (NSNetServiceBrowser *)aNetServiceBrowser 
  didFindService:(NSNetService *)aNetService 
  moreComing:(BOOL)moreComing
{
    [aNetService setDelegate:self];
    [aNetService resolve];
}

You receive three parameters: aNetServiceBrowser is the browser that sent the message, aNetService is the service that has been found and moreComing tells you if there are more queued service objects. The moreComing parameter looks a bit strange at first, but can be used as a hint to your user interface code to delay updating.

The information you are probably most interested in comes as the second parameter and it looks like this is already everything you need. Unfortunately you only get one third of the information you are interested in. You can send the service object a name message to get the name of the service. To obtain the IP address and port number you have to set a delegate and send a resolve message to the service. Don't forget to set the delegate, since this time the service will sent you messages, not the browser. When you send resolve this will again result in messages sent to the delegate. The interesting one this time is netServiceDidResolveAddress:.

Following the successful path lets start by looking at netServiceDidResolveAddress:. Listing 4 shows an implementation:

Listing 4:

Addresses resolved

- (void)netServiceDidResolveAddress:(NSNetService *)sender
{
    NSString           *name = nil;
    NSData             *address = nil;
    struct sockaddr_in *socketAddress = nil;
    NSString           *ipString = nil;
    int                port;
    
    for (i = 0; i < [[sender addresses] count]; i++)
    {
        name = [sender name];
        address = [[sender addresses] objectAtIndex:i];
        socketAddress = (struct sockaddr_in *)
          [address bytes];
        ipString = [NSString stringWithFormat: @"%s",
          inet_ntoa (socketAddress->sin_addr)];
        port = socketAddress->sin_port;
        [...]
     }
}

The only parameter is the service object that sent the message. Now the service object holds all the needed information to connect to the service. You obtain the name by sending a name message to the service. To find the IP address and port number you send an addresses message to the service. You receive an array containing all addresses. This array usually contains exactly one address, but to be on the save side loop through all addresses in the array. An address is of type sockaddr_in. This is a standard networking structure of Unix. See the above code for the details. After you have the name, IP and port you are ready to use that information. You will probably store the information in an array so you can access it any time you need it.

Lets go one step back to netServiceBrowser:didRemoveService:moreComing:. This message will be sent to you every time a service has been removed. If you stored the information in an array you have to remove the entry for that service to keep the array up-to-date.

Browsing problems

On Mac OS X 10.2.3 and before there is a problem with service browsing and switching locations. When you switch the location from the Apple menu (or change your IP address in any other way) the browser gets seriously confused. Your old and new IP may or may not show up. You may get entries that are simply wrong, pointing to your old IP address.

This happens with Apple's Rendezvous-enabled products, too. I saw myself showing up in iChat double after switching back and forth and Apple's AFPServer (the 'Personal File Sharing' server) also has problems with it, when you look at your logs.

It might be that this is already fixed when you read this, since Apple has released fixes to Rendezvous with every of the last three system updates. I read it is much better with Mac OS X 10.2.5, but to be nice to your users you should try to offer them a workaround on systems before 10.2.5 at least.

My suggestion is to offer refresh functionality. A refresh starts a complete new search forgetting about the cached entries.

If you want to automate this, you could regularly check if your IP address has changed (use [[NSHost currentHost] address] for this) and then refresh. The ARendezvousController class does not do this, but it offers a refreshBrowsing method that you can hook up to a button in your user interface easily.

Making things easier

By now you have a good overview of how to use Rendezvous. But like me, I guess you will think that you don't want to weave that all into your code every time you want to use Rendezvous.

Therefore I came up with ARendezvousController. It has a simplified interface and still provides everything to publish and browse services. An ARendezvousController object cares about one service type, publishing and browsing it. It provides start/stop methods for publishing and browsing. It has exactly one delegate method that is called every time something changes. It keeps track of the found services and on request returns an array with all found services, ready with name, IP address and port number. It even creates the socket others will connect to for you.

Listing 5:

Public interface of ARendezvousController

// public interface
@interface ARendezvousController : NSObject

- (id)initWithName:(NSString *)name type:(NSString *)type
  port:(int)port;
- (void)dealloc;
- (id)delegate;
- (void)setDelegate:(id)object;
- (NSString *)name;
- (BOOL)setName:(NSString *)name;
- (NSSocketPort *)socket;

- (void)activateBrowsing:(BOOL)flag;
- (BOOL)isBrowsing;
- (void)refreshBrowsing;
- (void)activatePublishing:(BOOL)flag;
- (BOOL)isPublished;
- (NSArray *)discoveredServicesWithInfo;

- (NSString *)ipForName:(NSString *)name;
- (int)portForName:(NSString *)name;

@end

// to be implemented by the delegate
@interface NSObject (RendezvousControllerDelegate)

- (void)discoveredServicesDidChange:(id)sender;

@end

Using ARendezvousController

Instead of going through the list method by method, lets start with a real world example. The following code will fill an NSTableView with all available services of type @"_demo._tcp." on your local network. The table view will be updated dynamically every time services are published and removed without user intervention. Just like you know it from iChat.

The complete demo project including ARendezvousController can be downloaded from <http://www.artissoftware.com/rendezvous>. This is probably the best way to proceed, since you don't have to create the .nib file in Interface Builder yourself.

If you are reading this without access to the Internet, here is what you need to create in Interface Builder: The main window contains an NSTableView. The NSTableView has three columns. The identifiers of the three columns should be "name", "ip" and "port".

Listing 6:

ADemoController.h

@interface ADemoController : NSObject
{
    IBOutlet NSWindow     *_mainWindow;
    IBOutlet NSTableView  *_tableView;
    ARendezvousController    *_rendezvousController;
    NSArray                *_lastState;
}
- (void)awakeFromNib;
- (void)discoveredServicesDidChange:(id)sender;
- (int)numberOfRowsInTableView:(NSTableView *)tableView;
- (id)tableView:(NSTableView *)tableView
  objectValueForTableColumn:(NSTableColumn *)tableColumn
  row:(int)row;
@end

In Interface Builder import this header file and connect the _mainWindow outlet to your window and the _tableView outlet to your table view.

Lets start by looking at awakeFromNib. This methods contains all the necessary setup:

Listing 7:

awakeFromNib

- (void)awakeFromNib
{
    _lastState = [[NSArray alloc] init];
    _rendezvousController = [[ARendezvousController alloc]
      initWithName:NSFullUserName() type:@"_demo._tcp."
      port:12345];
    [_rendezvousController setDelegate:self];
    [_rendezvousController activateBrowsing:YES];
    [_rendezvousController activatePublishing:YES];
    [_mainWindow center];
    [_mainWindow makeKeyAndOrderFront:self];
}

_lastState will contain a copy of the last state returned by the rendezvousController. In the beginning there are no services, so it is initialized as an empty array. After that the ARendezvousController is initialized with a type of @"_demo._tcp." and with port 12345. The port number is just a suggestion. If this port is already in use the number is increased as long as a socket can be created. This is no problem, since the port number is published. At this time the socket will be created. To obtain the socket you would send a socket message to the rendezvousController. Finally the delegate is set to self so we are notified of changes, browsing is started by sending activateBrowsing: and the service is published by sending activatePublishing: to the rendezvousController.

The next method is the delegate method.

Listing 8:

The delegate method

- (void)discoveredServicesDidChange:(id)sender
{
    [_lastState autorelease];
    _lastState = [[rendezvousController
      discoveredServicesWithInfo] retain];
    [_tableView reloadData];
}

It simply releases the old copy of states, asks the rendezvousController for an up-to-date array of states and retains that. After that it tells the table view to reload its data.

Finally these two methods fill the table view with data:

Listing 9:

Tableview methods

- (int)numberOfRowsInTableView:(NSTableView *)tableView
{
    return [_lastState count];
}
- (id)tableView:(NSTableView *)tableView
  objectValueForTableColumn:(NSTableColumn *)tableColumn
  row:(int)row
{
    return [[_lastState objectAtIndex:row]
      valueForKey:[tableColumn identifier]];
}

The last one is a wonderful demonstration of applied Cocoa magic, but to understand it you should know first that the array returned by discoveredServicesWithInfo contains an NSDictionary for every service. Such a dictionary contains three key/value pairs:

Key "name" contains an NSString with the name of the service

Key "ip" contains an NSString with the IP address (like @"192.168.0.1")

Key "port" contains an NSNumber with the port number

By setting the column identifiers of the table view to these keys the data can be fed to the table view with this one-liner.

That's it! It is that simple. In my next article I will show how to send messages over the network just like you would send it to your objects. This is called Distributed Objects. Stay tuned!

Listing 10:

ARendezvousController.h

#import <Foundation/Foundation.h>
// interface of the rendezvous class
@interface ARendezvousController : NSObject
{
    NSNetService  *_service;
    NSString      *_serviceName;
    NSString      *_serviceType;
    BOOL          _browsing;
    BOOL          _publishing;
    NSNetServiceBrowser  *_serviceBrowser;
    NSNetServiceBrowser  *_domainBrowser;
    NSSocketPort         *_socketPort;
    int                  _portNumber;
    NSMutableArray       *_discoveredServicesWithInfo;
    id                   _delegate;
}
- (id)initWithName:(NSString *)name type:(NSString *)type
  port:(int)port;
- (void)dealloc;
- (id)delegate;
- (void)setDelegate:(id)object;
- (NSString *)name;
- (BOOL)setName:(NSString *)name;
- (NSSocketPort *)socket;
- (void)activateBrowsing:(BOOL)flag;
- (BOOL)isBrowsing;
- (void)refreshBrowsing;
- (void)activatePublishing:(BOOL)flag;
- (BOOL)isPublished;
- (NSArray *)discoveredServicesWithInfo;
- (NSString *)ipForName:(NSString *)name;
- (int)portForName:(NSString *)name;
@end
// to be implemented by the delegate
@interface NSObject (RendezvousControllerDelegate)
- (void)discoveredServicesDidChange:(id)sender;
@end

Listing 11:

ARendezvousController.m

#import "ARendezvousController.h"
#include <netinet/in.h>
#include <arpa/inet.h>
@interface ARendezvousController (ARendezvousControllerInternal)
// creation
- (void)createSocket;
- (void)createBrowser;
- (void)createService;
// management
- (BOOL)addInfoService:(NSNetService *)
  service name:(NSString *)name ip:(NSString *)ip
  port:(int)port;
- (BOOL)removeInfoService:(NSNetService *)service;
// other
- (void)startBrowsing;
@end
@interface ARendezvousController (NSNetServiceDelegation)
// publication
- (void)netService:(NSNetService *)sender
  didNotPublish:(NSDictionary *)errorDict;
- (void)netServiceWillPublish:(NSNetService *)sender;
- (void)netServiceDidStop:(NSNetService *)sender;
// resolution
- (void)netService:(NSNetService *)sender
  didNotResolve:(NSDictionary *)errorDict;
- (void)netServiceDidResolveAddress:(NSNetService *)sender;
- (void)netServiceWillResolve:(NSNetService *)sender;
@end
@interface ARendezvousController
  (NSNetServiceBrowserDelegation)
// browsing
- (void)netServiceBrowser:(NSNetServiceBrowser *)
  aNetServiceBrowser didFindService:(NSNetService *)
  aNetService moreComing:(BOOL)moreComing;
- (void)netServiceBrowser:(NSNetServiceBrowser *)
  aNetServiceBrowser didNotSearch:(NSDictionary *)errorDict;
- (void)netServiceBrowser:(NSNetServiceBrowser *)
  aNetServiceBrowser didRemoveService:(NSNetService *)
  aNetService moreComing:(BOOL)moreComing;
- (void)netServiceBrowser:(NSNetServiceBrowser *)
  aNetServiceBrowser didFindDomain:(NSString *)domainString
  moreComing:(BOOL)moreComing;
- (void)netServiceBrowser:(NSNetServiceBrowser *)
  aNetServiceBrowser didRemoveDomain:(NSString *)domainString 
  moreComing:(BOOL)moreComing;
- (void)netServiceBrowserDidStopSearch:
  (NSNetServiceBrowser *)aNetServiceBrowser;
- (void)netServiceBrowserWillSearch:
  (NSNetServiceBrowser *)aNetServiceBrowser;
@end
@implementation ARendezvousController
- (id)initWithName:(NSString *)name type:(NSString *)type
  port:(int)port
{
    self = [super init];
    if (self)
    {
        // store name, type and port for later
        [self setName:name];
        _serviceType = [type retain];
        _portNumber = port;
        
        // initialize array
        _discoveredServicesWithInfo =
          [[NSMutableArray alloc] init];
        
        // create the socket and the browser
        [self createSocket];
        [self createBrowser];
    }
    return self;
}
- (void)dealloc
{
    // clean up
    [self activatePublishing:NO];
    [_serviceBrowser stop];
    [_domainBrowser stop];
    [_socketPort release];
    [_discoveredServicesWithInfo release];
    [super dealloc];
}
- (id)delegate
{
    return _delegate;
}
- (void)setDelegate:(id)object
{
    // find if delegate supports the delegation message
    if (![object respondsToSelector:
      @selector(discoveredServicesDidChange:)])
        NSLog (@"Delegate does not respond to 
          'discoveredServicesDidChange:'!");
    
    _delegate = object;
}
- (NSString *)name
{
    return _serviceName;
}
- (BOOL)setName:(NSString *)name
{
    // change name only when not already published
    if (!_publishing)
    {
        [name retain];
        [_serviceName release];
        _serviceName = name;
        return YES;
    }
    else
    {
        NSLog (@"Cannot change name while service
          is published!");
        return NO;
    }
}
- (NSSocketPort *)socket
{
    return _socketPort;
}
- (void)activateBrowsing:(BOOL)flag
{
    // if requested and actual state match don't proceed
    if (flag == _browsing)
        return;
    
    if (flag)
    {
        // activate browsing
        _browsing = YES;
        [_serviceBrowser searchForServicesOfType:
          _serviceType inDomain:@""];
    }
    else
    {
        // deactivate browsing
        _browsing = NO;
        [_serviceBrowser stop];
        [_discoveredServicesWithInfo removeAllObjects];
        [_delegate discoveredServicesDidChange:self];
    }
}
- (BOOL)isBrowsing
{
    return _browsing;
}
- (void)startBrowsing
{
    // should only be called when browsing off
    if (_browsing)
    {
        NSLog (@"Browing already started!");
        return;
    }
    
    // start browsing
    _browsing = YES;
    [_serviceBrowser searchForServicesOfType:
      _serviceType inDomain:@""];
}
- (void)refreshBrowsing
{
    // don't refresh if not browsing
    if (!_browsing)
        return;
    
    // start/stop
    // (stop is deferred to the end of message queue)
    [self activateBrowsing:NO];
    [self performSelector:@selector(startBrowsing)
      withObject:nil afterDelay:0.0];
}
- (void)activatePublishing:(BOOL)flag
{
    // if already activated then don't do anything
    if (_publishing == flag)
        return;
    
    if (flag)
    {
        // activate service
        [self createService];
    }
    else
    {
        // deactivate service
        [_service stop];
        _service = nil;
    }
    
    // set new state
    _publishing = flag;
}
- (BOOL)isPublished
{
    return _publishing;
}
- (NSArray *)discoveredServicesWithInfo
{
    // return (autoreleased) copy
    return [NSArray 
      arrayWithArray:_discoveredServicesWithInfo];
}
- (NSString *)ipForName:(NSString *)name
{
    NSEnumerator    *e = nil;
    NSDictionary    *dict = nil;
    
    // find the corresponding ip to the given name
    e = [_discoveredServicesWithInfo objectEnumerator];
    while (dict = [e nextObject])
        if ([[dict objectForKey:@"name"]
          isEqualToString:name])
            return [dict objectForKey:@"ip"];
    
    // return nil when not found
    return nil;
}
- (int)portForName:(NSString *)name
{
    NSEnumerator    *e = nil;
    NSDictionary    *dict = nil;
    
    // find the corresponding ip to the given name
    e = [_discoveredServicesWithInfo objectEnumerator];
    while (dict = [e nextObject])
        if ([[dict objectForKey:@"name"]
          isEqualToString:name])
            return [[dict objectForKey:@"port"] intValue];
    
    // return 0 when not found
    return 0;
}
@end
@implementation ARendezvousController
  (RendezvousControllerInternal)
- (void)createSocket
{
    // already there
    if (_socketPort)
        return;
    
    // look for free port
    while (!_socketPort)
    {
        _socketPort = [[NSSocketPort alloc]
          initWithTCPPort:_portNumber];
        _portNumber++;
    }
    _portNumber--;
}
- (void)createService
{
    // already there
    if (_service)
        return;
    
    // create service, make self the delegate and publish
    _service = [[NSNetService alloc] initWithDomain:@""
      type:_serviceType name:_serviceName port:_portNumber];
    [_service setDelegate:self];
    [_service publish];
}
- (void)createBrowser
{
    // setup service browser
    if (!_serviceBrowser)
    {
        _serviceBrowser = [[NSNetServiceBrowser alloc] init];
        [_serviceBrowser setDelegate:self];
    }
}
- (BOOL)addInfoService:(NSNetService *)service name:(NSString *)name ip:(NSString *)ip port:(int)port
{
    NSMutableDictionary    *dict = nil;
    NSEnumerator           *e = nil;
    
    // if already there then don't add
    e = [_discoveredServicesWithInfo objectEnumerator];
    while (dict = [e nextObject])
        if ([[dict objectForKey:@"ip"] isEqualToString:ip])
            if ([[dict objectForKey:@"port"] intValue] ==
              port)
                return NO;
    
    // add if not found in array
    dict = [NSMutableDictionary dictionary];
    [dict setObject:ip forKey:@"ip"];
    [dict setObject:[NSNumber numberWithInt:port]
      forKey:@"port"];
    [dict setObject:name forKey:@"name"];
    [dict setObject:service forKey:@"service"];
    [_discoveredServicesWithInfo addObject:dict];
    return YES;
}
- (BOOL)removeInfoService:(NSNetService *)service
{
    NSDictionary    *dict = nil;
    NSEnumerator    *e = nil;
    NSMutableArray  *delete = nil;
    
    // look for object with this service and mark for delete
    delete =[NSMutableArray array];
    e = [_discoveredServicesWithInfo objectEnumerator];
    while (dict = [e nextObject])
        if ([[dict objectForKey:@"service"] isEqual:service])
            [delete addObject:dict];
    
    // delete marked objects
    e = [delete objectEnumerator];
    while (dict = [e nextObject])
        [_discoveredServicesWithInfo removeObject:dict];
    
    return NO;
}
@end
@implementation ARendezvousController
  (NSNetServiceDelegation)
- (void)netService:(NSNetService *)sender
  didNotPublish:(NSDictionary *)errorDict
{
    // publishing failed
    _publishing = NO;
    NSLog (@"Publishing the service %@failed.",
      [sender name]);
    [_delegate discoveredServicesDidChange:self];
}
- (void)netServiceWillPublish:(NSNetService *)sender
{
    // does nothing for now,
    // implemented for your possible additions
}
- (void)netServiceDidStop:(NSNetService *)sender
{
    // does nothing for now,
    // implemented for your possible additions
}
- (void)netService:(NSNetService *)sender didNotResolve:(NSDictionary *)errorDict
{
    // resolving failed
    NSLog (@"Resolving of address for service %@ failed.",
      [sender name]);
}
- (void)netServiceDidResolveAddress:(NSNetService *)sender
{
    NSData              *address = nil;
    struct sockaddr_in  *socketAddress = nil;
    NSString            *ipString = nil;
    int                 port, i;
    
    for (i = 0; i < [[sender addresses] count]; i++)
    {
        // gather data about this published service
        address = [[sender addresses] objectAtIndex:i];
        socketAddress = (struct sockaddr_in *)
          [address bytes];
        ipString = [NSString stringWithFormat: @"%s",
          inet_ntoa (socketAddress->sin_addr)];
        port = socketAddress->sin_port;
        
        // published localhost is a Rendezvous strangeness:
        // ignore that!
        if ([ipString isEqualToString:@"127.0.0.1"])
            continue;
        
        // notify delegate of change
        if ([self addInfoService:sender name:[sender name]
          ip:ipString port:port])
            [_delegate discoveredServicesDidChange:self];
    }
}
- (void)netServiceWillResolve:(NSNetService *)sender
{
    // does nothing for now,
    // implemented for your possible additions
}
@end
@implementation ARendezvousController
  (NSNetServiceBrowserDelegation)
- (void)netServiceBrowser:(NSNetServiceBrowser *)
  aNetServiceBrowser didFindService:(NSNetService *)
  aNetService moreComing:(BOOL)moreComing
{
    // add to dicovered services and resolve it
    [aNetService setDelegate:self];
    [aNetService resolve];
}
- (void)netServiceBrowser:(NSNetServiceBrowser *)
  aNetServiceBrowser didRemoveService:(NSNetService *)
  aNetService moreComing:(BOOL)moreComing
{
    // remove and notify
    [self removeInfoService:aNetService];
    [_delegate discoveredServicesDidChange:self];
}
- (void)netServiceBrowserDidStopSearch:
  (NSNetServiceBrowser *)aNetServiceBrowser
{
    // empty the arrays and notify delegate
    if (aNetServiceBrowser == _serviceBrowser)
    {
        [_discoveredServicesWithInfo removeAllObjects];
        [_delegate discoveredServicesDidChange:self];
    }
}
- (void)netServiceBrowser:(NSNetServiceBrowser *)
  aNetServiceBrowser didNotSearch:(NSDictionary *)errorDict
{
    NSLog (@"Unable to search.");
}
- (void)netServiceBrowserWillSearch:(NSNetServiceBrowser *)
  aNetServiceBrowser
{
    // does nothing for now,
    // implemented for your possible additions
}
- (void)netServiceBrowser:(NSNetServiceBrowser *)
  aNetServiceBrowser didFindDomain:(NSString *)domainString
  moreComing:(BOOL)moreComing
{
    // does nothing for now,
    // implemented for your possible additions
}
- (void)netServiceBrowser:(NSNetServiceBrowser *)
  aNetServiceBrowser didRemoveDomain:(NSString *)domainString 
  moreComing:(BOOL)moreComing
{
    // does nothing for now,
    // implemented for your possible additions
}
@end

Bibliography and References

Apple Computer. "Rendezvous Network Services" <http://developer.apple.com/techpubs/macosx/...>

Michael Beam. "Incorporating Rendezvous into Your Cocoa Applications"

<http://www.macdevcenter.com/pub/a/mac/2002/11/08/cocoa.html>


Wolfgang Ante is the founder of ARTIS Software (http://www.artissoftware.com). In the last 14 years he worked on Macintosh products for ARTIS and lots of other companies, including a product that won the Macworld's Editors Choice Award. At the time he is trying hard to transform ARTIS into a successful Mac OS X shareware company. Beside that he is always happy to offer his experience for working on your project. You can reach him at wolfgang@artissoftware.com.

 
AAPL
$102.50
Apple Inc.
+0.25
MSFT
$45.43
Microsoft Corpora
+0.55
GOOG
$571.60
Google Inc.
+2.40

MacTech Search:
Community Search:

Software Updates via MacUpdate

Skype 6.19.0.450 - Voice-over-internet p...
Skype allows you to talk to friends, family and co-workers across the Internet without the inconvenience of long distance telephone charges. Using peer-to-peer data transmission technology, Skype... Read more
VueScan 9.4.41 - Scanner software with a...
VueScan is a scanning program that works with most high-quality flatbed and film scanners to produce scans that have excellent color fidelity and color balance. VueScan is easy to use, and has... Read more
Cloud 3.0.0 - File sharing from your men...
Cloud is simple file sharing for the Mac. Drag a file from your Mac to the CloudApp icon in the menubar and we take care of the rest. A link to the file will automatically be copied to your clipboard... Read more
LibreOffice 4.3.1.2 - Free Open Source o...
LibreOffice is an office suite (word processor, spreadsheet, presentations, drawing tool) compatible with other major office suites. The Document Foundation is coordinating development and... Read more
SlingPlayer Plugin 3.3.20.505 - Browser...
SlingPlayer is the screen interface software that works hand-in-hand with the hardware inside the Slingbox to make your TV viewing experience just like that at home. It features an array of... Read more
Get Lyrical 3.8 - Auto-magically adds ly...
Get Lyrical auto-magically add lyrics to songs in iTunes. You can choose either a selection of tracks, or the current track. Or turn on "Active Tagging" to get lyrics for songs as you play them.... Read more
Viber 4.2.2 - Send messages and make cal...
Viber lets you send free messages and make free calls to other Viber users, on any device and network, in any country! Viber syncs your contacts, messages and call history with your mobile device,... Read more
Cocktail 7.6 - General maintenance and o...
Cocktail is a general purpose utility for OS X that lets you clean, repair and optimize your Mac. It is a powerful digital toolset that helps hundreds of thousands of Mac users around the world get... Read more
LaunchBar 6.1 - Powerful file/URL/email...
LaunchBar is an award-winning productivity utility that offers an amazingly intuitive and efficient way to search and access any kind of information stored on your computer or on the Web. It provides... Read more
Maya 2015 - Professional 3D modeling and...
Maya is an award-winning software and powerful, integrated 3D modeling, animation, visual effects, and rendering solution. Because Maya is based on an open architecture, all your work can be scripted... Read more

Latest Forum Discussions

See All

Rhonna Designs Magic (Photography)
Rhonna Designs Magic 1.0 Device: iOS Universal Category: Photography Price: $1.99, Version: 1.0 (iTunes) Description: Want to sprinkle *magic* on your photos? With RD Magic, you can add colors, filters, light leaks, bokeh, edges,... | Read more »
This Week at 148Apps: August 25-29, 2014
Shiny Happy App Reviews   | Read more »
Qube Kingdom – Tips, Tricks, Strategies,...
Qube Kingdom is a tower defense game from DeNA. You rally your troops – magicians, archers, knights, barbarians, and others – and fight against an evil menace looking to dominate your kingdom of tiny squares. Planning a war isn’t easy, so here are a... | Read more »
Qube Kingdom Review
Qube Kingdom Review By Nadia Oxford on August 29th, 2014 Our Rating: :: KIND OF A SQUARE KINGDOMUniversal App - Designed for iPhone and iPad Qube Kingdom has cute visuals, but it’s a pretty basic tower defense game at heart.   | Read more »
Fire in the Hole Review
Fire in the Hole Review By Rob Thomas on August 29th, 2014 Our Rating: :: WALK THE PLANKUniversal App - Designed for iPhone and iPad Seafoam’s Fire in the Hole looks like a bright, 8-bit throwback, but there’s not enough booty to... | Read more »
Alien Creeps TD is Now Available Worldwi...
Alien Creeps TD is Now Available Worldwide Posted by Ellis Spice on August 29th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Dodo Master Review
Dodo Master Review By Jordan Minor on August 29th, 2014 Our Rating: :: NEST EGGiPad Only App - Designed for the iPad Dodo Master is tough but fair, and that’s what makes it a joy to play.   | Read more »
Motorsport Manager Review
Motorsport Manager Review By Lee Hamlet on August 29th, 2014 Our Rating: :: MARVELOUS MANAGEMENTUniversal App - Designed for iPhone and iPad Despite its depth and sense of tactical freedom, Motorsport Manager is one of the most... | Read more »
Motorsport Manager – Beginner Tips, Tric...
The world of Motorsport management can be an unforgiving and merciless one, so to help with some of the stress that comes with running a successful race team, here are a few hints and tips to leave your opponents in the dust. | Read more »
CalPal Update Brings the App to 2.0, Add...
CalPal Update Brings the App to 2.0, Adds Lots of New Stuff Posted by Ellis Spice on August 29th, 2014 [ permalink ] | Read more »

Price Scanner via MacPrices.net

Apple now offering refurbished 21-inch 1.4GHz...
The Apple Store is now offering Apple Certified Refurbished 21″ 1.4GHz iMacs for $929 including free shipping plus Apple’s standard one-year warranty. Their price is $170 off the cost of new models,... Read more
Save $50 on the 2.5GHz Mac mini, on sale for...
B&H Photo has the 2.5GHz Mac mini on sale for $549.99 including free shipping. That’s $50 off MSRP, and B&H will also include a free copy of Parallels Desktop software. NY sales tax only. Read more
Save up to $300 on an iMac with Apple refurbi...
The Apple Store has Apple Certified Refurbished iMacs available for up to $300 off the cost of new models. Apple’s one-year warranty is standard, and shipping is free. These are the best prices on... Read more
The Rise of Phablets
Carlisle & Gallagher Consulting Group, a businesses and technology consulting firm focused solely on the financial services industry, has released an infographic depicting the convergence of... Read more
Bad Driver Database App Allows Good Drivers t...
Bad Driver Database 1.4 by Facile Group is a new iOS and Android app that lets users instantly input and see how many times a careless, reckless or just plain stupid driver has been added to the... Read more
Eddy – Cloud Music Player for iPhone/iPad Fre...
Ukraine based CapableBits announces the release of Eddy, its tiny, but smart and powerful cloud music player for iPhone and iPad that allows users to stream or download music directly from cloud... Read more
A&D Medical Launches Its WellnessConnecte...
For consumers and the healthcare providers and loved ones who care for them, A&D Medical, a leader in connected health and biometric measurement devices and services, has launched its... Read more
Anand Lal Shimpi Retires From AnandTech
Anand Lal Shimpi, whose AnandTech Website is famous for its meticulously detailed and thoroughgoing reviews and analysis, is packing it in. Lal Shimpi, who founded the tech site at age 14 in 1997,... Read more
2.5GHz Mac mini, Apple refurbished, in stock...
The Apple Store has Apple Certified Refurbished 2.5GHz Mac minis available for $509, $90 off MSRP. Apple’s one-year warranty is included, and shipping is free. Read more
13-inch 2.5GHz MacBook Pro on sale for $999,...
B&H Photo has the 13″ 2.5GHz MacBook Pro on sale for $999.99 including free shipping plus NY sales tax only. Their price is $100 off MSRP. Read more

Jobs Board

*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
Senior Event Manager, *Apple* Retail Market...
…This senior level position is responsible for leading and imagining the Apple Retail Team's global event strategy. Delivering an overarching brand story; in-store, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.