-
- All Implemented Interfaces:
-
java.io.Serializable
public class TransportAddress extends InetSocketAddress
The Address class is used to define destinations to outgoing Stun Packets.
-
-
Constructor Summary
Constructors Constructor Description TransportAddress(String hostname, int port, Transport transport)
Creates an address instance address from an IP address and a port number. TransportAddress(Array<byte> ipAddress, int port, Transport transport)
Creates an address instance address from a byte array containing an IP address and a port number. TransportAddress(InetSocketAddress address, Transport transport)
Creates an address instance from an InetSocketAddress. TransportAddress(InetAddress address, int port, Transport transport)
Creates an address instance from a host name and a port number.
-
Method Summary
Modifier and Type Method Description Transport
getTransport()
The transport that this transport address is suggesting. Array<byte>
getAddressBytes()
Returns the raw IP address of this Address object. String
toString()
Constructs a string representation of this InetSocketAddress. String
getHostAddress()
Returns the host address. 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. boolean
isIPv6()
Returns true if this is an IPv6 address and false otherwise. boolean
canReach(TransportAddress dst)
Determines whether this TransportAddress is theoretically capable of communicating with dst. -
-
Constructor Detail
-
TransportAddress
TransportAddress(String hostname, int port, Transport transport)
Creates an address instance address from an IP address and a port number.- Parameters:
hostname
- The IP addressport
- The port numbertransport
- The transport that this address would be bound to.
-
TransportAddress
TransportAddress(Array<byte> ipAddress, int port, Transport transport)
Creates an address instance address from a byte array containing an IP address and a port number.- Parameters:
ipAddress
- The IP addressport
- The port numbertransport
- The Transport to use with this address.
-
TransportAddress
TransportAddress(InetSocketAddress address, Transport transport)
Creates an address instance from an InetSocketAddress.- Parameters:
address
- the address and port.transport
- the transport to use with this address.
-
TransportAddress
TransportAddress(InetAddress address, int port, Transport transport)
Creates an address instance from a host name and a port number.- Parameters:
address
- the address itselfport
- the port numbertransport
- the transport to use with this address.
-
-
Method Detail
-
getTransport
Transport getTransport()
The transport that this transport address is suggesting.
-
getAddressBytes
Array<byte> getAddressBytes()
Returns the raw IP address of this Address object. The result is in network byte order: the highest order byte of the address is in getAddress()[0].
-
toString
String toString()
Constructs a string representation of this InetSocketAddress. This String is constructed by calling toString() on the InetAddress and concatenating the port number (with a colon). If the address is unresolved then the part before the colon will only contain the host name.
-
getHostAddress
String getHostAddress()
Returns the host address.
-
equals
boolean equals(TransportAddress transportAddress)
Determines whether this TransportAddress is value equal to a specific TransportAddress.
- Parameters:
transportAddress
- the TransportAddress to test for value equality with this TransportAddress
-
equalsTransportAddress
boolean equalsTransportAddress(Object obj)
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 address.
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.
- Parameters:
obj
- the object to compare against.
-
isIPv6
boolean isIPv6()
Returns true if this is an IPv6 address and false otherwise.
-
canReach
boolean canReach(TransportAddress dst)
Determines whether this TransportAddress is theoretically capable of communicating with dst. An address is certain not to be able to communicate with another if they do not have the same Transport or family.
- Parameters:
dst
- the TransportAddress that we'd like to check for reachability from this one.
-
-
-
-