
public static String getHostIpAddress() {
String hostIp = "";
InetAddress netAddress = getInetAddress();
hostIp = getHostIp(netAddress);
return hostIp;
}
public static InetAddress getInetAddress() {
try {
return InetAddressgetLocalHost();
} catch (UnknownHostException e) {
Systemoutprintln("unknown host!");
}
return null;
}
public static String getHostIp(InetAddress netAddress) {
if (null == netAddress) {
return null;
}
String ip = netAddressgetHostAddress(); // get the ip address
return ip;
}
public static String getHostName(InetAddress netAddress) {
if (null == netAddress) {
return null;
}
String name = netAddressgetHostName(); // get the host address
return name;
}
外网:
public static String getWebIp() {
try {
String strUrl = ">
以上就是关于java中怎么获取客户端的真实的ip和端口号全部的内容,包括:java中怎么获取客户端的真实的ip和端口号、java代码实现由request请求消息获取远处发送请求的用户主机的内网IP地址和外网IP地址、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)