类 NetUtils
- java.lang.Object
-
- com.alibaba.dubbo.common.utils.NetUtils
-
public class NetUtils extends Object
IP and Port Helper for RPC
-
-
构造器概要
构造器 构造器 说明 NetUtils()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static String
filterLocalHost(String host)
static int
getAvailablePort()
static int
getAvailablePort(int port)
static String
getHostName(String address)
static String
getIpByHost(String hostName)
static InetAddress
getLocalAddress()
Find first valid IP from local network cardstatic String
getLocalHost()
static InetSocketAddress
getLocalSocketAddress(String host, int port)
static int
getRandomPort()
static boolean
isAnyHost(String host)
static boolean
isInvalidLocalHost(String host)
static boolean
isInvalidPort(int port)
static boolean
isLocalHost(String host)
static boolean
isValidAddress(String address)
static boolean
isValidLocalHost(String host)
static void
joinMulticastGroup(MulticastSocket multicastSocket, InetAddress multicastAddress)
static void
setInterface(MulticastSocket multicastSocket, boolean preferIpv6)
static InetSocketAddress
toAddress(String address)
static String
toAddressString(InetSocketAddress address)
static String
toURL(String protocol, String host, int port, String path)
-
-
-
方法详细资料
-
getRandomPort
public static int getRandomPort()
-
getAvailablePort
public static int getAvailablePort()
-
getAvailablePort
public static int getAvailablePort(int port)
-
isInvalidPort
public static boolean isInvalidPort(int port)
-
isValidAddress
public static boolean isValidAddress(String address)
-
isLocalHost
public static boolean isLocalHost(String host)
-
isAnyHost
public static boolean isAnyHost(String host)
-
isInvalidLocalHost
public static boolean isInvalidLocalHost(String host)
-
isValidLocalHost
public static boolean isValidLocalHost(String host)
-
getLocalSocketAddress
public static InetSocketAddress getLocalSocketAddress(String host, int port)
-
getLocalHost
public static String getLocalHost()
-
getLocalAddress
public static InetAddress getLocalAddress()
Find first valid IP from local network card- 返回:
- first valid local IP
-
getIpByHost
public static String getIpByHost(String hostName)
- 参数:
hostName
-- 返回:
- ip address or hostName if UnknownHostException
-
toAddressString
public static String toAddressString(InetSocketAddress address)
-
toAddress
public static InetSocketAddress toAddress(String address)
-
joinMulticastGroup
public static void joinMulticastGroup(MulticastSocket multicastSocket, InetAddress multicastAddress) throws IOException
- 抛出:
IOException
-
setInterface
public static void setInterface(MulticastSocket multicastSocket, boolean preferIpv6) throws IOException
- 抛出:
IOException
-
-