|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgnu.cajo.utils.Multicast
public final class Multicast
This class can listen for UDP multicasts over the network, as well as to send out UDP announcements. The mechanism is rigged to send a reference to a remote object as a zipped MarshalledObject (zedmob). It also allows a listening object to receive announced object referencess via a callback mechanism. A single VM can use as many Multicast objects as it wishes.
Note: this class requires that the network routers be configured to pass IP multicast packets, at least for the multicast address used. If not, the packets will will only exist within the subnet of origination.
Field Summary | |
---|---|
java.lang.String |
address
A reference to the address on which this object is operating. |
java.net.InetAddress |
host
The network interface on which this multicast object is listening |
java.net.InetAddress |
iaddr
A reference to the address of the calling VM, when the object is listening. |
RemoteInvoke |
item
A reference to a received remote object reference, when the object is listening. |
int |
port
A reference to the port on which this object is operating. |
Constructor Summary | |
---|---|
Multicast()
The default constructor sets the internal fields to default values which should be sufficient for most purposes. |
|
Multicast(java.lang.String address,
int port)
This constructor allows creation of Multicast objects on any appropriate multicast address, and port number. |
|
Multicast(java.lang.String host,
java.lang.String address,
int port)
The full constructor allows creation of Multicast objects on any appropriate address, and port number. |
Method Summary | |
---|---|
void |
announce(java.lang.Object item,
int ttl)
This method is used to make UDP announcements on the network. |
void |
announce(java.lang.Object item,
int ttl,
java.lang.Object proxy)
This method is used to make UDP announcements on the network. |
void |
listen(java.lang.Object callback)
This method starts a thead to listen on the construction address and port . |
static void |
main(java.lang.String[] args)
The application method loads a zipped marshalled object (zedmob) to a proxy from a URL, or a file, and allows it run in this virtual machine. |
void |
run()
The monitor thread, it listens for multicasts. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final java.net.InetAddress host
public final java.lang.String address
public final int port
public java.net.InetAddress iaddr
public RemoteInvoke item
Constructor Detail |
---|
public Multicast() throws java.net.UnknownHostException
java.net.UnknownHostException
- If the default network interface
could not be resolved, not very likely.public Multicast(java.lang.String address, int port) throws java.net.UnknownHostException
address
- The multicast socket domain name, or address, on which
this object will listen. It can be any address in the range 224.0.0.1
through 239.255.255.255.port
- The UDP port number on which this object will announce and
listen, its value can be 0 - 65535. It is completely independent of all
TCP port numbers. Application specific meaning could be assigned to port
numbers, to identify broadcast types.
java.net.UnknownHostException
- If the specified host address
could not be resolved, or is invalid.public Multicast(java.lang.String host, java.lang.String address, int port) throws java.net.UnknownHostException
host
- The network interface on which to send or receive multicasts,
specified when a machine has more than one, otherwise use "0.0.0.0" to
send and receive on all of themaddress
- The multicast socket domain name, or address, on which
this object will listen. It can be any address in the range 224.0.0.1
through 239.255.255.255.port
- The UDP port number on which this object will announce and
listen, its value can be 0 - 65535. It is completely independent of all
TCP port numbers. Application specific meaning could be assigned to port
numbers, to identify broadcast types.
java.net.UnknownHostException
- If the specified host address
could not be resolved, or is invalid.Method Detail |
---|
public void announce(java.lang.Object item, int ttl) throws java.io.IOException
item
- The object reference to be sent in the announcement
packet, if it is not already remoted, it will be, automatically.ttl
- The time-to-live of the broadcast packet. This roughly
specifies how many multicast enabled routers will pass this packet before
automatically discarding it. For example 16, should cover a medium sized
LAN. The maximum value is 255, which could theoretically cover the globe,
that is, in 1999. A value of 1 confines the packet to its immediate
subnet.
java.io.IOException
- If a datagram socket could not be created, or the
packet could not be sent.public void announce(java.lang.Object item, int ttl, java.lang.Object proxy) throws java.io.IOException
item
- The object reference to be sent in the announcement
packet, if it is not already remoted, it will be, automatically.ttl
- The time-to-live of the broadcast packet. This roughly
specifies how many multicast enabled routers will pass this packet before
automatically discarding it. For example 16, should cover a medium sized
LAN. The maximum value is 255, which could theoretically cover the globe,
that is, in 1999. A value of 1 confines the packet to its immediate
subnet.proxy
- The proxy object to be sent to requesting clients.
java.io.IOException
- If a datagram socket could not be created, or the
packet could not be sent.public void listen(java.lang.Object callback)
address
and port
. The listening object will be called on
its public multicast method, with a reference to the calling Multicast
object. This is to allow the possibility for a single listener, to
monitor multiple multicast objects. If a listener is used to monitor
multiple multicast objects, it may be invoked reentrantly, otherwise it
cannot. Listening will continue until the callback object's multicast
method retruns a non-null value. If it does, this method would havt to
be called again to restart listening.
callback
- An object, presumably local to this VM, which is to
receive notifications about announcements.
java.lang.IllegalArgumentException
- If the object is actively listening, at
the time of the invocation.public void run()
listen
method again.
run
in interface java.lang.Runnable
public static void main(java.lang.String[] args) throws java.lang.Exception
getitem
method of the Remote
class to load the object. Following loading,
it will also create an rmiregistry, and bind a remote reference to it
under the name "main". This can allow remote clients to connect to, and
interact with, the object. It will announce its startup on a default
Multicast object, and then begin listening on it for further
announcements, which will be passed to the loaded proxy object. It can
be configured using the following arguments, all arguments subsequent to
the ones specified in the command line can be omitted:
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |