public class TransportAddress extends InetSocketAddress
Modifier and Type | Field and Description |
---|---|
private static long |
serialVersionUID
our serial version UID;
|
private Transport |
transport
The variable that we are using to store the transport that this address
is pertaining to.
|
Constructor and Description |
---|
TransportAddress(byte[] ipAddress,
int port,
Transport transport)
Creates an address instance address from a byte array containing an IP
address and a port number.
|
TransportAddress(InetAddress address,
int port,
Transport transport)
Creates an address instance from a host name and a port number.
|
TransportAddress(InetSocketAddress address,
Transport transport)
Creates an address instance from an InetSocketAddress.
|
TransportAddress(String hostname,
int port,
Transport transport)
Creates an address instance address from an IP address and a port number.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canReach(TransportAddress dst)
Determines whether this TransportAddress is theoretically
capable of communicating with dst.
|
boolean |
equals(TransportAddress transportAddress)
Determines whether this TransportAddress is value equal to a
specific TransportAddress.
|
boolean |
equalsTransportAddress(Object obj)
Compares this object against the specified object.
|
byte[] |
getAddressBytes()
Returns the raw IP address of this Address object.
|
String |
getHostAddress()
Returns the host address.
|
Transport |
getTransport()
The transport that this transport address is suggesting.
|
boolean |
isIPv6()
Returns true if this is an IPv6 address and false
otherwise.
|
String |
toString()
Constructs a string representation of this InetSocketAddress.
|
createUnresolved, equals, getAddress, getHostName, getHostString, getPort, hashCode, isUnresolved
private static final long serialVersionUID
private final Transport transport
public TransportAddress(String hostname, int port, Transport transport)
A valid port value is between 0 and 65535. A port number of zero will let the system pick up an ephemeral port in a bind operation.
A null address will assign the wildcard address.
hostname
- The IP addressport
- The port numbertransport
- The transport that this address would be bound to.IllegalArgumentException
- if the port parameter is outside the
specified range of valid port values.public TransportAddress(byte[] ipAddress, int port, Transport transport) throws UnknownHostException
A valid port value is between 0 and 65535. A port number of zero will let the system pick up an ephemeral port in a bind operation.
A null address will assign the wildcard address.
ipAddress
- The IP addressport
- The port numbertransport
- The Transport to use with this address.UnknownHostException
- UnknownHostException if IP address is of
illegal lengthpublic TransportAddress(InetSocketAddress address, Transport transport)
address
- the address and port.transport
- the transport to use with this address.IllegalArgumentException
- if the port parameter is outside the
range of valid port values, or if the host name parameter is
null.public TransportAddress(InetAddress address, int port, Transport transport)
An attempt will be made to resolve the host name into an InetAddress. If that attempt fails, the address will be flagged as unresolved.
A valid port value is between 0 and 65535. A port number of zero will let the system pick up an ephemeral port in a bind operation.
address
- the address itselfport
- the port numbertransport
- the transport to use with this address.IllegalArgumentException
- if the port parameter is outside the
range of valid port values, or if the host name parameter is
null.public byte[] getAddressBytes()
public String toString()
toString
in class InetSocketAddress
public String getHostAddress()
public Transport getTransport()
public boolean equals(TransportAddress transportAddress)
transportAddress
- the TransportAddress to test for value
equality with this TransportAddressequalsTransportAddress(Object)
public boolean equalsTransportAddress(Object obj)
Two instances of TransportAddress represent the same address if both the InetAddresses (or hostnames if it is unresolved), port numbers, and Transports are equal. If both addresses are unresolved, then the hostname, the port and the Transport are compared.
obj
- the object to compare against.InetAddress.equals(java.lang.Object)
public boolean isIPv6()
public boolean canReach(TransportAddress dst)
dst
- the TransportAddress that we'd like to check for
reachability from this one.TransportAddress
shares the same
Transport and family as dst or false
otherwise.Copyright © 2018. All rights reserved.