java.lang.Object
java.net.SocketAddress
net.i2p.client.streaming.I2PSocketAddress
- All Implemented Interfaces:
Serializable
A SocketAddress (Destination + port) so we can have SocketChannels. Ports are not widely used in I2P, in most cases the port will be zero. See InetSocketAddress for javadocs.
- See Also:
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DestinationThe I2P destination.private final StringHostname from the constructor.private final intPort number, 0 if not specified.private static final longSerial version unique identifier.Constructor Summary
ModifierConstructorDescriptionprivateI2PSocketAddress(int port, String host) Creates an address without resolving anything.I2PSocketAddress(String host) Convenience constructor that parses host:port.I2PSocketAddress(String host, int port) Does a naming service lookup to resolve the dest.I2PSocketAddress(Destination dest, int port) Does not do a reverse lookup.Method Summary
Modifier and TypeMethodDescriptionstatic I2PSocketAddresscreateUnresolved(String host, int port) Creates an unresolved address for the given host and port.booleanWhether this address equals another, comparing port, destination, and host.Does a naming service lookup to resolve the dest if this was created unresolved or if the resolution failed in the constructor.Host name of this address, as given in the constructor.intgetPort()The port number of this address.inthashCode()Hash code of this address.booleanWhether the destination has not been resolved.toString()String representation of this address.
Field Details
serialVersionUID
private static final long serialVersionUIDSerial version unique identifier.- See Also:
_port
private final int _portPort number, 0 if not specified._dest
The I2P destination._host
Hostname from the constructor.
Constructor Details
I2PSocketAddress
Convenience constructor that parses host:port. Does a naming service lookup to resolve the dest. May take several seconds for b32.- Parameters:
host- hostname or b64 dest or b32, may have :port appended- Throws:
IllegalArgumentException- for port < 0 or port > 65535 or invalid port
I2PSocketAddress
Does not do a reverse lookup. Host will be null.- Parameters:
dest- the destination to address, which must not be nullport- the TCP port on that destination, from 0 to 65535- Throws:
IllegalArgumentException- for port < 0 or port > 65535
I2PSocketAddress
Does a naming service lookup to resolve the dest. May take several seconds for b32.- Parameters:
host- the hostname to resolve, e.g. a b32 address or an .i2p nameport- the TCP port on the resolved destination, from 0 to 65535- Throws:
IllegalArgumentException- for port < 0 or port > 65535
I2PSocketAddress
Creates an address without resolving anything.- Parameters:
port- the TCP port, from 0 to 65535host- the hostname or address, may be null
Method Details
createUnresolved
Creates an unresolved address for the given host and port.- Parameters:
host- the hostname to record now and resolve on the first getAddress() callport- the TCP port on the destination, from 0 to 65535- Returns:
- an address holding that host and port, with no destination yet
- Throws:
IllegalArgumentException- for port < 0 or port > 65535
getPort
public int getPort()The port number of this address.- Returns:
- the port number, 0 if not specified
getAddress
Does a naming service lookup to resolve the dest if this was created unresolved or if the resolution failed in the constructor. If unresolved, this may take several seconds for b32.- Returns:
- the resolved destination, or null if the lookup failed
getHostName
Host name of this address, as given in the constructor.- Returns:
- the host only if given in the constructor. Does not do a reverse lookup.
isUnresolved
public boolean isUnresolved()Whether the destination has not been resolved.- Returns:
- true if this address was created unresolved or resolution failed
toString
equals
hashCode