类 NetUtils
- java.lang.Object
 - 
- com.alibaba.dubbo.common.utils.NetUtils
 
 
- 
public class NetUtils extends Object
IP and Port Helper for RPC 
- 
- 
构造器概要
构造器 构造器 说明 NetUtils() 
- 
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static StringfilterLocalHost(String host)static intgetAvailablePort()static intgetAvailablePort(int port)static StringgetHostName(String address)static StringgetIpByHost(String hostName)static InetAddressgetLocalAddress()Find first valid IP from local network cardstatic StringgetLocalHost()static InetSocketAddressgetLocalSocketAddress(String host, int port)static intgetRandomPort()static booleanisAnyHost(String host)static booleanisInvalidLocalHost(String host)static booleanisInvalidPort(int port)static booleanisLocalHost(String host)static booleanisValidAddress(String address)static booleanisValidLocalHost(String host)static voidjoinMulticastGroup(MulticastSocket multicastSocket, InetAddress multicastAddress)static voidsetInterface(MulticastSocket multicastSocket, boolean preferIpv6)static InetSocketAddresstoAddress(String address)static StringtoAddressString(InetSocketAddress address)static StringtoURL(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
 
 - 
 
 -