程序包 com.sh.util
类 InetUtil
java.lang.Object
com.sh.util.InetUtil
Description:
Title:聚天业务架构平台(SHGather)
- 从以下版本开始:
- Jan 21, 2014
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static int返回一个空闲的端口号,用于获取随机空闲端口,因此获取到该端口后需要马上使用,只能保证获取当时端口有效static String获取hostnamestatic StringgetHostNameOfIP(String ipPort) 接收一个ip(或包含端口)的字符串static InetAddressstatic String获取本机IPstatic String遍历网卡获取本机IPstatic StringnormalizeHostName(String name) Given a string representation of a host, return its ip address in textual presentation.normalizeHostNames(Collection<String> names) Given a collection of string representation of hosts, return a list of corresponding IP addresses in the textual representation.static booleanportEnable(int port) 端口是否可用
-
构造器详细资料
-
InetUtil
public InetUtil()
-
-
方法详细资料
-
portEnable
public static boolean portEnable(int port) 端口是否可用- 参数:
port- 检测端口号- 返回:
- true 可用 false 不可用
-
normalizeHostName
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
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
接收一个ip(或包含端口)的字符串- 参数:
ipPort- 字符串,开始:ip[:port]- 返回:
- 获取到字符串中的ip信息
-
getHostname
获取hostname- 返回:
- String
-
getFreeSocketPort
public static int getFreeSocketPort()返回一个空闲的端口号,用于获取随机空闲端口,因此获取到该端口后需要马上使用,只能保证获取当时端口有效- 返回:
- 当前空闲端口号
-
getLocalIp
获取本机IP- 返回:
-
getLocalIp2
遍历网卡获取本机IP- 返回:
-
getLocalInetAddress
-