Package org.apache.zookeeper.common
Class NetUtils
java.lang.Object
org.apache.zookeeper.common.NetUtils
This class contains common utilities for netstuff. Like printing IPv6 literals correctly
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Prefer using the hostname for formatting, but without requesting reverse DNS lookup.static String[]
getIPV6HostAndPort
(String hostPort) Separates host and port from given host port string if host port string is enclosed within square bracket.
-
Constructor Details
-
NetUtils
public NetUtils()
-
-
Method Details
-
formatInetAddr
Prefer using the hostname for formatting, but without requesting reverse DNS lookup. Fall back to IP address if hostname is unavailable and use [] brackets for IPv6 literal. -
getIPV6HostAndPort
Separates host and port from given host port string if host port string is enclosed within square bracket.- Parameters:
hostPort
- host port string- Returns:
- String[]{host, port} if host port string is host:port or String[] {host, port:port} if host port string is host:port:port or String[] {host} if host port string is host or String[]{} if not a ipv6 host port string.
-