InetAddress

InetAddress

# new InetAddress()

class contains properties and methods for InetAddress

Methods

# (static) getAllByName(host) → {Array.<InetAddress>}

Parameters:
Name Type Description
host String

host name value to be used for searching

Returns:
Type
Array.<InetAddress>

# (static) getByAddress(host, addr) → {InetAddress}

Parameters:
Name Type Description
host string
addr Array.<byte>
Returns:
Type
InetAddress

# (static) getByAddress(addr) → {InetAddress}

Parameters:
Name Type Description
addr Array.<byte>
Returns:
Type
InetAddress

# (static) getByName(host) → {string}

Parameters:
Name Type Description
host null

the specified host, or .

Returns:

an IP address for the given host name.

Type
string

# (static) getLocalHost() → {InetAddress}

Returns:
Type
InetAddress

# (static) getLoopbackAddress() → {InetAddress}

Returns:
Type
InetAddress

# equals(obj) → {boolean}

Compares this object against the specified object. The result is {true} if and only if the argument is not {null} and it represents the same IP address as this object. Two instances of {InetAddress} represent the same IP address if the length of the byte arrays returned by {getAddress} is the same for both, and each of the array components is the same for the byte arrays.

Parameters:
Name Type Description
obj Object

the object to compare against.

Returns:
Type
boolean

# getAddress() → {Array.<byte>}

Returns the raw IP address of this {InetAddress} object. The result is in network byte order: the highest order byte of the address is in {getAddress()[0]}.

Returns:

the raw IP address of this object.

Type
Array.<byte>

# getCanonicalHostName() → {String}

Gets the fully qualified domain name for this IP address. Best effort method, meaning we may not be able to return the FQDN depending on the underlying system configuration If there is a security manager, this method first calls its {checkConnect} method with the hostname and {-1} as its arguments to see if the calling code is allowed to know the hostname for this IP address, i.e., to connect to the host. If the operation is not allowed, it will return the textual representation of the IP address.

Since:
  • 1.4
Returns:

the fully qualified domain name for this IP address, or if the operation is not allowed by the security check, the textual representation of the IP address

Type
String

# getHostAddress() → {String}

Returns the IP address string in textual presentation.

Since:
  • 1.0.2
Returns:

the raw IP address in a string format.

Type
String

# getHostName() → {string}

Gets the host name for this IP address. If this InetAddress was created with a host name, this host name will be remembered and returned; If there is a security manager, its {checkConnect} method is first called with the hostname and {-1} as its arguments to see if the operation is allowed. If the operation is not allowed, it will return the textual representation of the IP address.

See:
Returns:

the host name for this IP address, or if the operation is not allowed by the security check, the textual representation of the IP address.

Type
string

# hashCode() → {number}

Returns a hashcode for this IP address.

Returns:

a hash code value for this IP address.

Type
number

# isAnyLocalAddress() → {boolean}

Utility routine to check if the InetAddress is a wildcard address.

Returns:

indicating if the Inetaddress is a wildcard address.

Type
boolean

# isLinkLocalAddress() → {boolean}

Utility routine to check if the InetAddress is an link local address.

Returns:

indicating if the InetAddress is a link local address; or false if address is not a link local unicast address.

Type
boolean

# isLoopbackAddress() → {boolean}

Utility routine to check if the InetAddress is a loopback address.

Returns:

indicating if the InetAddress is a loopback address; or false otherwise.

Type
boolean

# isMCGlobal() → {boolean}

Utility routine to check if the multicast address has global scope.

Returns:

indicating if the address has is a multicast address of global scope, false if it is not of global scope or it is not a multicast address

Type
boolean

# isMCLinkLocal() → {boolean}

Utility routine to check if the multicast address has link scope.

Returns:

indicating if the address has is a multicast address of link-local scope, false if it is not of link-local scope or it is not a multicast address

Type
boolean

# isMCNodeLocal() → {boolean}

Utility routine to check if the multicast address has node scope.

Returns:

indicating if the address has is a multicast address of node-local scope, false if it is not of node-local scope or it is not a multicast address

Type
boolean

# isMCOrgLocal() → {boolean}

Utility routine to check if the multicast address has organization scope.

Returns:

indicating if the address has is a multicast address of organization-local scope, false if it is not of organization-local scope or it is not a multicast address

Type
boolean

# isMCSiteLocal() → {boolean}

Utility routine to check if the multicast address has site scope.

Returns:

indicating if the address has is a multicast address of site-local scope, false if it is not of site-local scope or it is not a multicast address

Type
boolean

# isMulticastAddress() → {boolean}

Utility routine to check if the InetAddress is an IP multicast address.

Returns:

indicating if the InetAddress is an IP multicast address

Type
boolean

# isReachable(timeout) → {boolean}

Test whether that address is reachable. Best effort is made by the implementation to try to reach the host, but firewalls and server configuration may block requests resulting in a unreachable status while some specific ports may be accessible. A typical implementation will use ICMP ECHO REQUESTs if the privilege can be obtained, otherwise it will try to establish a TCP connection on port 7 (Echo) of the destination host. The timeout value, in milliseconds, indicates the maximum amount of time the try should take. If the operation times out before getting an answer, the host is deemed unreachable. A negative value will result in an IllegalArgumentException being thrown.

Parameters:
Name Type Description
timeout

the time, in milliseconds, before the call aborts

Returns:

indicating if the address is reachable.

Type
boolean

# isSiteLocalAddress() → {boolean}

Utility routine to check if the InetAddress is a site local address.

Returns:

indicating if the InetAddress is a site local address; or false if address is not a site local unicast address.

Type
boolean

# toString() → {String}

Converts this IP address to a String. The string returned is of the form: hostname / literal IP address.If the host name is unresolved, no reverse name service lookup is performed. The hostname part will be represented by an empty string.

Returns:

a string representation of this IP address.

Type
String