Java Reference
In-Depth Information
The isMCSiteLocal() method returns true if the address is a site-wide multicast ad‐
dress, false otherwise. Packets addressed to a site-wide address will only be transmitted
within their local site. Site-wide multicast addresses begin with FF05 or FF15, depending
on whether the multicast address is a well known permanently assigned address or a
transient address.
The isMCLinkLocal() method returns true if the address is a subnet-wide multicast
address, false otherwise. Packets addressed to a link-local address will only be trans‐
mitted within their own subnet. Link-local multicast addresses begin with FF02 or FF12,
depending on whether the multicast address is a well known permanently assigned
address or a transient address.
The isMCNodeLocal() method returns true if the address is an interface-local multicast
address, false otherwise. Packets addressed to an interface-local address are not sent
beyond the network interface from which they originate, not even to a different network
interface on the same node. This is primarily useful for network debugging and testing.
Interface-local multicast addresses begin with the two bytes FF01 or FF11, depending
on whether the multicast address is a well known permanently assigned address or a
transient address.
The method name is out of sync with current terminology. Earlier
drafts of the IPv6 protocol called this type of address “node-local,”
hence the name “isMCNodeLocal.” The IPNG working group actual‐
ly changed the name before this method was added to the JDK, but
Sun didn't get the memo in time.
Example 4-6 is a simple program to test the nature of an address entered from the
command line using these 10 methods.
Example 4-6. Testing the characteristics of an IP address
import java.net.* ;
public class IPCharacteristics {
public static void main ( String [] args ) {
try {
InetAddress address = InetAddress . getByName ( args [ 0 ]);
if ( address . isAnyLocalAddress ()) {
System . out . println ( address + " is a wildcard address." );
}
if ( address . isLoopbackAddress ()) {
System . out . println ( address + " is loopback address." );
}
Search WWH ::




Custom Search