Oracle

com.compoze.util
Class MulticastDiscoveryClient

java.lang.Object
  extended by com.compoze.util.MulticastDiscoveryClient

public class MulticastDiscoveryClient
extends java.lang.Object

This class provides a client which can discover a server by creating a multicast request.


Nested Class Summary
 class MulticastDiscoveryClient.Server
          Class description.
 
Constructor Summary
MulticastDiscoveryClient(java.net.InetAddress multicastGroup, int iPort, int iMagicNumber)
          Constructor.
MulticastDiscoveryClient(java.net.InetAddress multicastGroup, int iPort, int iMagicNumber, int iTimeToLive)
          Constructor.
 
Method Summary
 java.util.Collection discover()
          Send a multicast request and return the first server that responds, using a timeout of 3 seconds.
 java.util.Collection discover(int iTimeout)
          Send a multicast request and return the first server that responds.
 java.util.Collection discover(int iTimeout, int iRetries)
          Send a multicast request and return the first server that responds.
protected  void finalize()
          Finalize.
static void main(java.lang.String[] args)
          Main.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MulticastDiscoveryClient

public MulticastDiscoveryClient(java.net.InetAddress multicastGroup,
                                int iPort,
                                int iMagicNumber,
                                int iTimeToLive)
                         throws java.io.IOException
Constructor.

Parameters:
multicastGroup - the multicast group
iPort - the multicast port
iMagicNumber - the magic number
iTimeToLive - time to live for send packet
Throws:
java.io.IOException - if an i/o error occurred

MulticastDiscoveryClient

public MulticastDiscoveryClient(java.net.InetAddress multicastGroup,
                                int iPort,
                                int iMagicNumber)
                         throws java.io.IOException
Constructor.

Parameters:
multicastGroup - the multicast group
iPort - the multicast port
iMagicNumber - the magic number
iTimeToLive - time to live for send packet
Throws:
java.io.IOException - if an i/o error occurred
Method Detail

discover

public java.util.Collection discover()
                              throws java.io.IOException
Send a multicast request and return the first server that responds, using a timeout of 3 seconds.

Parameters:
iTimeout - the number of milliseconds to wait before timing out
Returns:
a collection of servers
Throws:
java.io.IOException - if an i/o error occurred

discover

public java.util.Collection discover(int iTimeout)
                              throws java.io.IOException
Send a multicast request and return the first server that responds.

Parameters:
iTimeout - the number of milliseconds to wait before timing out
iRetries - the number of retries to make
Returns:
a collection of servers
Throws:
java.io.IOException - if an i/o error occurred

discover

public java.util.Collection discover(int iTimeout,
                                     int iRetries)
                              throws java.io.IOException
Send a multicast request and return the first server that responds.

Parameters:
iTimeout - the number of milliseconds to wait before timing out
iRetries - the number of retries to make
Returns:
a collection of servers
Throws:
java.io.IOException - if an i/o error occurred

finalize

protected void finalize()
                 throws java.lang.Throwable
Finalize. Called by garbage collector to free resources.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - anything may be thrown in a finalizer

main

public static void main(java.lang.String[] args)
Main.

Parameters:
args - command line arguments

Oracle

Copyright ©1999-2008 Oracle All rights reserved.