public final class Multicast extends Object implements Runnable
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.
| Modifier and Type | Field and Description |
|---|---|
String |
address
A reference to the address on which this object is operating.
|
InetAddress |
host
The network interface on which this multicast object is listening
|
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 and Description |
|---|
Multicast()
The default constructor sets the internal fields to default values which
should be sufficient for most purposes.
|
Multicast(String address,
int port)
This constructor allows creation of Multicast objects on any
appropriate multicast address, and port number.
|
Multicast(String host,
String address,
int port)
The full constructor allows creation of Multicast objects on any
appropriate address, and port number.
|
| Modifier and Type | Method and Description |
|---|---|
void |
announce(Object item,
int ttl)
This method is used to make UDP announcements on the network.
|
void |
announce(Object item,
int ttl,
Object proxy)
This method is used to make UDP announcements on the network.
|
void |
listen(Object callback)
|
static void |
main(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.
|
public final InetAddress host
public final String address
public final int port
public InetAddress iaddr
public RemoteInvoke item
public Multicast()
throws UnknownHostException
UnknownHostException - If the default network interface
could not be resolved, not very likely.public Multicast(String address, int port) throws 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.UnknownHostException - If the specified host address
could not be resolved, or is invalid.public Multicast(String host, String address, int port) throws 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.UnknownHostException - If the specified host address
could not be resolved, or is invalid.public void announce(Object item, int ttl) throws 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.IOException - If a datagram socket could not be created, or the
packet could not be sent.public void announce(Object item, int ttl, Object proxy) throws 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.IOException - If a datagram socket could not be created, or the
packet could not be sent.public void listen(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.IllegalArgumentException - If the object is actively listening, at
the time of the invocation.public void run()
listen method again.public static void main(String[] args) throws 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:ExceptionCopyright © 2016. All Rights Reserved.