程序包 com.sh.util

类 InetUtil

java.lang.Object
com.sh.util.InetUtil

public class InetUtil extends Object

Description:

Title:聚天业务架构平台(SHGather)

从以下版本开始:
Jan 21, 2014
  • 构造器详细资料

    • InetUtil

      public InetUtil()
  • 方法详细资料

    • portEnable

      public static boolean portEnable(int port)
      端口是否可用
      参数:
      port - 检测端口号
      返回:
      true 可用 false 不可用
    • normalizeHostName

      public static String normalizeHostName(String name)
      Given a string representation of a host, return its ip address in textual presentation.
      参数:
      name - a string representation of a host: either a textual representation its IP address or its host name
      返回:
      its IP address in the string format
    • normalizeHostNames

      public static List<String> normalizeHostNames(Collection<String> names)
      Given a collection of string representation of hosts, return a list of corresponding IP addresses in the textual representation.
      参数:
      names - a collection of string representations of hosts
      返回:
      a list of corresponding IP addresses in the string format
    • getHostNameOfIP

      public static String getHostNameOfIP(String ipPort)
      接收一个ip(或包含端口)的字符串
      参数:
      ipPort - 字符串,开始:ip[:port]
      返回:
      获取到字符串中的ip信息
    • getHostname

      public static String getHostname()
      获取hostname
      返回:
      String
    • getFreeSocketPort

      public static int getFreeSocketPort()
      返回一个空闲的端口号,用于获取随机空闲端口,因此获取到该端口后需要马上使用,只能保证获取当时端口有效
      返回:
      当前空闲端口号
    • getLocalIp

      public static String getLocalIp()
      获取本机IP
      返回:
    • getLocalIp2

      public static String getLocalIp2()
      遍历网卡获取本机IP
      返回:
    • getLocalInetAddress

      public static InetAddress getLocalInetAddress()