public class InetSocketAddressUtil extends Object
NetUtil.createByteArrayFromIpAddressString(java.lang.String)
utility method and the
InetSocketAddress instances will created in a way that these instances are resolved
initially. This removes the need to do unnecessary reverse DNS lookups.Constructor and Description |
---|
InetSocketAddressUtil() |
Modifier and Type | Method and Description |
---|---|
static InetSocketAddress |
createInetSocketAddress(String hostname,
int port,
boolean resolve)
Creates InetSocketAddress instance.
|
static InetSocketAddress |
createResolved(String hostname,
int port)
Creates InetSocketAddress that is always resolved.
|
static InetSocketAddress |
createUnresolved(String hostname,
int port)
Creates unresolved InetSocketAddress.
|
static InetSocketAddress |
replaceUnresolvedNumericIp(InetSocketAddress inetSocketAddress)
Replaces an unresolved InetSocketAddress with a resolved instance in the case that
the passed address is a numeric IP address (both IPv4 and IPv6 are supported).
|
static InetSocketAddress |
replaceWithResolved(InetSocketAddress inetSocketAddress)
Replaces an unresolved InetSocketAddress with a resolved instance in the case that
the passed address is unresolved.
|
public static InetSocketAddress createUnresolved(String hostname, int port)
hostname
- ip-address or hostnameport
- port numberpublic static InetSocketAddress createResolved(String hostname, int port)
hostname
- ip-address or hostnameport
- port numberpublic static InetSocketAddress createInetSocketAddress(String hostname, int port, boolean resolve)
hostname
- ip-address or hostnameport
- port numberresolve
- when true, resolve given hostname at instance creation timepublic static InetSocketAddress replaceWithResolved(InetSocketAddress inetSocketAddress)
inetSocketAddress
- socket address instance to processpublic static InetSocketAddress replaceUnresolvedNumericIp(InetSocketAddress inetSocketAddress)
inetSocketAddress
- socket address instance to process