Top Description Constructors Methods
reactor.netty.transport

public final Class AddressUtils

extends Object
Class Inheritance
Imports
java.net.Inet4Address, .Inet6Address, .InetAddress, .InetSocketAddress, .SocketAddress, .UnknownHostException, java.util.function.Supplier, io.netty.channel.unix.DomainSocketAddress, io.netty.util.NetUtil, reactor.util.annotation.Nullable

Internal class that creates unresolved or resolved InetSocketAddress instances Numeric IPv4 and IPv6 addresses will be detected and parsed by using Netty's NetUtil#createByteArrayFromIpAddressString utility method and the InetSocketAddress instances will be created in a way that these instances are resolved initially. This removes the need to do unnecessary reverse DNS lookups.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static InetAddress
pack-priv static InetSocketAddress
createForIpString(String hostname, int port)

public static InetSocketAddress

Returns:

InetSocketAddress for given parameters
createInetSocketAddress
(String
ip-address or hostname
hostname
,
int
port number
port
,
boolean
when true, resolve given hostname at instance creation time
resolve
)

Creates InetSocketAddress instance.

public static InetSocketAddress

Returns:

InetSocketAddress for given parameters
createResolved
(String
ip-address or hostname
hostname
,
int
port number
port
)

Creates InetSocketAddress that is always resolved.

public static InetSocketAddress

Returns:

InetSocketAddress for given parameters
createUnresolved
(String
ip-address or hostname
hostname
,
int
port number
port
)

Creates unresolved InetSocketAddress.

public static InetSocketAddress

Returns:

InetSocketAddress for given parameters, only numeric IP addresses will be resolved
parseAddress
(String
ip-address or hostname
address
,
int
the default port
defaultPort
)

Parse unresolved InetSocketAddress.

public static InetSocketAddress

Returns:

InetSocketAddress for given parameters, only numeric IP addresses will be resolved
parseAddress
(String
ip-address or hostname
address
,
int
is used if the address does not contain a port, or if the port cannot be parsed in non-strict mode
defaultPort
,
boolean
if true throws an exception when the address cannot be parsed, otherwise an unresolved InetSocketAddress is returned. It can include the case of the host having been parsed but not the port (replaced by defaultPort)
strict
)

Parse unresolved InetSocketAddress.

public static InetSocketAddress

Returns:

processed socket address instance
replaceUnresolvedNumericIp
(InetSocketAddress
socket address instance to process
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).

public static InetSocketAddress

Returns:

resolved instance with same host string and port
replaceWithResolved
(InetSocketAddress
socket address instance to process
inetSocketAddress
)

Replaces an unresolved InetSocketAddress with a resolved instance in the case that the passed address is unresolved.

public static SocketAddress

Returns:

the updated address
updateHost
(Supplier<? extends SocketAddress>
the address supplier
address
,
String
the new host string
host
)

Update the provided address with the new host string.

public static SocketAddress

Returns:

the updated address
updatePort
(Supplier<? extends SocketAddress>
the address supplier
address
,
int
the new port
port
)

Update the provided address with the new port.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AddressUtilsback to summary
private AddressUtils()

Method Detail

attemptParsingIpStringback to summary
pack-priv static InetAddress attemptParsingIpString(String hostname)
Annotations
@Nullable
createForIpStringback to summary
pack-priv static InetSocketAddress createForIpString(String hostname, int port)
Annotations
@Nullable
createInetSocketAddressback to summary
public static InetSocketAddress createInetSocketAddress(String hostname, int port, boolean resolve)

Creates InetSocketAddress instance. Numeric IP addresses will be detected and resolved without doing reverse DNS lookups.

Parameters
hostname:String

ip-address or hostname

port:int

port number

resolve:boolean

when true, resolve given hostname at instance creation time

Returns:InetSocketAddress

InetSocketAddress for given parameters

createResolvedback to summary
public static InetSocketAddress createResolved(String hostname, int port)

Creates InetSocketAddress that is always resolved. Numeric IP addresses will be detected and resolved without doing reverse DNS lookups.

Parameters
hostname:String

ip-address or hostname

port:int

port number

Returns:InetSocketAddress

InetSocketAddress for given parameters

createUnresolvedback to summary
public static InetSocketAddress createUnresolved(String hostname, int port)

Creates unresolved InetSocketAddress. Numeric IP addresses will be detected and resolved.

Parameters
hostname:String

ip-address or hostname

port:int

port number

Returns:InetSocketAddress

InetSocketAddress for given parameters

parseAddressback to summary
public static InetSocketAddress parseAddress(String address, int defaultPort)

Parse unresolved InetSocketAddress. Numeric IP addresses will be detected and resolved.

Parameters
address:String

ip-address or hostname

defaultPort:int

the default port

Returns:InetSocketAddress

InetSocketAddress for given parameters, only numeric IP addresses will be resolved

parseAddressback to summary
public static InetSocketAddress parseAddress(String address, int defaultPort, boolean strict)

Parse unresolved InetSocketAddress. Numeric IP addresses will be detected and resolved.

Parameters
address:String

ip-address or hostname

defaultPort:int

is used if the address does not contain a port, or if the port cannot be parsed in non-strict mode

strict:boolean

if true throws an exception when the address cannot be parsed, otherwise an unresolved InetSocketAddress is returned. It can include the case of the host having been parsed but not the port (replaced by defaultPort)

Returns:InetSocketAddress

InetSocketAddress for given parameters, only numeric IP addresses will be resolved

replaceUnresolvedNumericIpback to summary
public 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).

Parameters
inetSocketAddress:InetSocketAddress

socket address instance to process

Returns:InetSocketAddress

processed socket address instance

replaceWithResolvedback to summary
public static InetSocketAddress replaceWithResolved(InetSocketAddress inetSocketAddress)

Replaces an unresolved InetSocketAddress with a resolved instance in the case that the passed address is unresolved.

Parameters
inetSocketAddress:InetSocketAddress

socket address instance to process

Returns:InetSocketAddress

resolved instance with same host string and port

updateHostback to summary
public static SocketAddress updateHost(Supplier<? extends SocketAddress> address, String host)

Update the provided address with the new host string.

Parameters
address:Supplier<? extends SocketAddress>

the address supplier

host:String

the new host string

Returns:SocketAddress

the updated address

updatePortback to summary
public static SocketAddress updatePort(Supplier<? extends SocketAddress> address, int port)

Update the provided address with the new port.

Parameters
address:Supplier<? extends SocketAddress>

the address supplier

port:int

the new port

Returns:SocketAddress

the updated address