realbasic-nug
[Top] [All Lists]

Re: Using Mutex

To: Roger Clary <roger at classonesoftware dot com>
Subject: Re: Using Mutex
From: Joe Huber <joehuber at talasoft dot com>
Date: Sun, 30 Sep 2007 20:24:28 -0700
Cc: REALbasic Mailing List <realbasic-nug at lists dot realsoftware dot com>
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <8D344B96-66A8-4368-B87C-EFA9245AADC7 at classonesoftware dot com> <47003FC5 dot 4070000 at bellsouth dot net> <3C5A5B57-C7B1-493B-9125-C5781608C64A at classonesoftware dot com> <p06240803c325f6541190 at [10 dot 0 dot 1 dot 193]> <12F43D6F-0D39-4253-8B46-B9BEF2DF2A5D at classonesoftware dot com>
>>If you're sure that all the clients would be on the same LAN, you 
>>might consider using either the AutoDiscover class or a UDP socket 
>>to a multicast group address directly. These would be a pretty 
>>quick and easy solution, but the detection would not likely span 
>>across a router, so it wouldn't be useful in larger networks where 
>>the users might be separated from each other or the server by one 
>>or more routers.
>>
>>Regards,
>>Joe Huber
>
>Thanks Walter and Joe.
>I'll see if I can make sense of how to use the Autodiscovery class.
>Any suggestions from someone who has tried this before?

First you need to pick a multicast address for all the instances of 
your app to communicate on. Anything sent to a multicast address will 
be received by all members of the group who subscribed to that 
address. When you first start up your app can join that multicast 
group to listen for any other instances on that LAN. Initially, and 
periodically if desired, you can send your own home made query 
message to the multicast group saying that you're alive, and asking 
if any other copies of your app are active on that LAN.

Then it's up to you to enforce your desired policy regarding how many 
copies are allowed to run simultaneously and what action you take 
when you detect an overage.

You'll need a unique address for each node, it's IP address would 
probably suffice. If you plan to allow more than one simultaneous 
copy, you might also keep a cache of addresses you've heard from 
recently, listen for announcements of when each app shuts down 
normally, time out the stale entries and then you'll know the number 
of simultaneous users.

If you just want a simple mechanism to know if another copy is 
running, just announce yourself when you first start up and if 
another copy of your app responds then just display an appropriate 
user message and shut yourself down.

Joe Huber
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>