Special

Clearance Sale!

We've been publishing for over five years now and it's time to clear out our inventory of back issues, so we're slashing prices!

RBD Magazines

Check out this amazing clearance sale of all our past issues. Missing some issues? This is a great time to complete your RBD collection. Save up to 40% off the regular price of our printed back issue packages. These prices are only good until the end of the year May 2008 and supplies are limited, so place your order today.

Article Preview


Buy Now

Print:
PDF:

Feature

Auto-Discovery Via UDP

How to automatically find other instances of your applications across a local network.

Issue: 2.2 (October/November 2003)
Author: Aaron Ballman
Author Bio: Aaron Ballman is the official networking guru of REAL Software. All your base are belong to him.
Article Description: No description available.
Article Length (in bytes): 9,172
Starting Page Number: 27
RBD Number: 2212
Resource File(s):

Download Icon 2212.sit Updated: Friday, October 17, 2003 at 12:45 PM

Related Link(s): None
Known Limitations: None

Excerpt of article text...

There are many situations where it would be useful to find out who else on your internal network is running a copy of your application. This is useful for things like doing network checks, or maybe you would like to add a chat feature to your application. There are any number of reasons you might like to have this sort of functionality. With the UDPSocket, this is a fairly easy thing to do.

When you want to discover what other applications are on the network, you need to send out a simple query over the network that any interested applications can hear. To do this, we need to come up with a protocol for your application to implement to do these queries and their appropriate responses. Let's start by trying to understand the process of what goes on when you need to automatically discover an application.

Auto-discovery, by its nature, is an asynchronous process. You have to start the ball rolling and see what occurs some time later. There are a few initialization and finalization issues you need to contend with, but those are fairly trivial. The first thing your application needs to do is, in its Open event, register itself to a multicast group and send out a message saying "I am here! Who else is here?" That is all the initialization you need to do. This lets other copies of your application know that something interesting has happened (you signed on), and allows them to respond (by telling you who they are). You will also need, in your Close event, a message that says "I'm leaving!" and remove yourself from the multicast group. This allows the other applications to take note of the interesting event. If one of the applications on the network crashes, it isn't a problem. We solve this possible problem with intermittent queries to see what applications are still responding. These queries can either happen at specific intervals (like every five minutes), or they can happen just before you need to do something interesting. For instance, you can query the network before saving a file to see if any other applications appeared, so you can see if this copy is perhaps pirated. Don't worry about the details yet; just be aware that we will have all situations covered.

...End of Excerpt. Please purchase the magazine to read the full article.

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com