Java Network Programming InetAddress class is a class that represents an IP address. InetAddress has no constructor. It uses its static method class to return the InetAddress object. GetByAddresspublic static InetAddress getByAddress (byte [] addr) throws UnknownHostExceptionpublic static InetAddress getByAddress (String host, byte [] addr) throws UnknownHostException no matter whether the ip address indicated by addr exists, creates an InetAddress object for this IP address. The host name in the second method is not necessarily the real name of the ip host expressed by addr. This host is only used to represent the alias. GetByNamepublic static InetAddress getByName (String host) throws writable static InetAddress [] getAllByName (String host) throws writable method public boolean isReachable (int timeout) throws IOExceptionpublic boolean isReachable (NetworkInterface netif, int, ttl, int timeout) throws IOException the first overload has a timeout parameter. You can use this parameter to set the connection timeout (unit: milliseconds ). The second overload mode has two additional parameters: netif and ttl. The netif parameter allows you to use a NetworkInterface object to determine which network interface the client uses to test the connectivity of the host. Ttl refers to the maximum number of connection hops during the connectivity test. The maximum number of routes that pass from the client to the remote host is the maximum number of connection hops. The isReachable method is to connect the client to the server by connecting to the echo port of the host. However, using this method on the Internet may fail to connect to the remote host due to factors such as the fire wall (in fact, the remote host can be connected). Therefore, isReachable is not reliable on the Internet. However, we can apply the isReachable method. Deny access to a website through an ip address (HTTP status code: 403) some websites clearly enter the correct ip address but cannot access the website, this is because the server verifies the Host field in the HTTP request header to prevent users from directly accessing the website through IP addresses. DNS Cache // set DNS Cache timeout to args [1] seconds java. security. security. setProperty ("networkaddress. cache. ttl ", args [1]); Security class www.2cto. comThisclass centralizes all security properties and common securitymethods. one of its primary uses is to manage providers. networkaddress. cache. ttl attribute in jdk/usr/lib/jvm/jdk7/jre/lib/security/java. in the security file, the parameter args [1] indicates the cache time, and-1 indicates the permanent cache. The NetworkInterface class (Network Interface Information) does not have any constructor. Public static NetworkInterface getByInetAddress (InetAddress addr) throws SocketExceptionpublic static NetworkInterface getByName (String name) throws SocketExceptionSocket programming on the client can be connected to the server in two ways: ip address and domain name in java, the domain name resolution function has been included in the Socket class, so we can use the domain name like ip.