>>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>
|