标签:get net 获取IP地址 localhost com ethos 3.1 概念 跳过
前面提及的:OSI,TCP-IP,IP地址,端口,协议概念我都清楚,所以我直接跳过前面,来到使用这里。
//获取本机IP InetAddress ip = InetAddress.getLocalHost(); System.out.println(ip); //***/169.254.93.173 String sip = ip.getHostAddress(); String name = ip.getHostName(); System.out.println(name+" "+ sip); //获取其他主机信息 ip = InetAddress.getByName("www.baidu.com"); System.out.println(ip);
标签:get net 获取IP地址 localhost com ethos 3.1 概念 跳过
原文地址:https://www.cnblogs.com/-nbloser/p/9689015.html