Use the InetAddress class to determine the special IP address

IP addresses are divided into ordinary addresses and special addresses. Ten methods provided by InetAddress class are used to determine whether an IP address is a special IP address@ H_ 301_ 1@

1、 Isanylocaladdress method @ h_ 301_ 1@

翻译错误 TIMEOUT

2、 Isloopbackaddress method @ h_ 301_ 1@

Returns true when the IP address is a loopback address; otherwise, returns false The loopback address is the IP address representing the local machine. The range of loopback addresses for IPv4 is 127.0 0.0 ~ 127.255. 255.255, that is, as long as the first byte is 127, it is the lookback address. Such as 127.1 2.3、127.0. 200.200 are loopback addresses. The loopback address of IPv6 is 0:0:0:0:0:0:0:1, which can also be abbreviated as:: 1 We can make @ h_ 301_ 1@

@H_ 301_ 1@

3、 Islinklocaladdress method @ h_ 301_ 1@

True is returned when the IP address is the linklocaladdress, otherwise false is returned. The range of IPv4 local connection address is 169.254.0.0 ~ 169.254.255.255. The first 12 bits of IPv6 local connection address are fe8, and other bits can take any value, such as fe88:: and fe80:: ABCD:: are local connection addresses. @ h_301_1@

4、 Issitelocaladdress method @ h_ 301_ 1@

When the IP address is a regional local address (sitelocaladdress) returns true, otherwise false. The IPv4 address is divided into three segments: 10.0.0.0 ~ 10.255.255.255, 172.16.0.0 ~ 172.31.255.255, 192.168.0.0 ~ 192.168.255.255. The first 12 bits of the IPv6 local address are FEC, and other bits can be arbitrary values, such as fed0:: and fef1:: are all regional local addresses. @ h_301_1@

5、 Ismulticastaddress method @ h_ 301_ 1@

When the IP address is a broadcast address (multicastaddress) returns true, otherwise false. Information can be sent to all computers in the network through the broadcast address, rather than only to a specific computer. The range of IPv4 broadcast address is 224.0.0.0 ~ 239.255.255.255. The first byte of IPv6 broadcast address is FF, and other bytes can be any value. Details about broadcast address It will be discussed in later chapters@ H_ 301_ 1@

6、 Ismcglobal method @ h_ 301_ 1@

Returns true when the IP address is a worldwide broadcast address; otherwise, returns false Worldwide broadcast addresses can send information to all computers on the Internet. IPv4 broadcast address except 224.0 0.0 and the IP address whose first byte is 239 are broadcast addresses worldwide. In the global broadcast address of IPv6, the first byte is FF, the second byte is 0e ~ Fe, and other bytes can be any value, such as ffbe:: and ff0e:: are global broadcast addresses@ H_ 301_ 1@

7、 Ismclinklocal method @ h_ 301_ 1@

Return true when the IP address is the subnet broadcast address, otherwise return false Using the broadcast address of the subnet can only send information to computers within the subnet. The range of subnet broadcast addresses for IPv4 is 224.0 0.0 ~ 224.0. 0.255. The first byte of IPv6 subnet broadcast address is FF, and the range of the second byte is 02 ~ F2. Other bytes can be any value, such as ffb2:: and ff02: ABCD:: are subnet broadcast addresses@ H_ 301_ 1@

8、 Ismcnodelocal method @ h_ 301_ 1@

Return true when the IP address is the broadcast address of the local interface; otherwise, return false The local interface broadcast address cannot send broadcast information to the network interface generating broadcast information, even another network interface of the same computer. All IPv4 broadcast addresses are not local interface broadcast addresses. The first byte of IPv6 local interface broadcast address is FF, and the range of the second node word is 01 ~ F1. Other bytes can be any value, such as ffb1:: and ff01: A123:: are local interface broadcast addresses@ H_ 301_ 1@

9、 Ismcoglocal method @ h_ 301_ 1@

When the IP address is an organization wide broadcast address, true is returned; otherwise, false is returned The organization wide broadcast address can be used to send broadcast information to all computers within the company or enterprise. The first byte of the IPv4 organization wide broadcast address is 239, the second byte is not less than 192, and the third byte is not more than 195, such as 239.193 100.200、 239.192. 195.0 are organization wide broadcast addresses. The first byte of the organization wide broadcast address of IPv6 is FF, the range of the second byte is 08 ~ F8, and other bytes can be any value, such as ff08:: and ff48:: are organization wide broadcast addresses@ H_ 301_ 1@

10、 Ismcsitelocal method @ h_ 301_ 1@

Return true when the IP address is a site wide broadcast address, otherwise return false Using the site wide broadcast address, you can send broadcast information to computers within the site. The range of site broadcast addresses for IPv4 is 239.255 0.0 ~ 239.255. 255.255, such as 239.255 1.1、239.255. 0.0 is the site wide broadcast address. The first byte of IPv6 site wide broadcast address is FF, the second byte is 05 ~ F5, and other bytes can be any value, such as ff05:: and ff45:: are site wide broadcast addresses@ H_ 301_ 1@

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>