Socket

Socket中获得本机ip地址

用InetAddress address=InetAddress.getLocalHost();
//获得本机IP地址
try {
InetAddress address=InetAddress.getLocalHost();
System.out.println(address);
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
快捷键 Alt+/是提示字的
win+R——>cmd—->ipconfig是查看本机ip地址的

你可能感兴趣的:(Socket)