[英]how to use InetAddress in Windows host with firewall
I want to get an example or suggestion of how to use InetAddress in windows systems with firewall active. 我想得到一个示例或建议如何在防火墙处于活动状态的Windows系统中使用InetAddress。 I don't know what is blocked by the firewall that isn't allowing this class in windows to work.
我不知道防火墙阻止什么阻止Windows中的这个类工作。
When I try to use this code in windows with firewall disabled I get the host name and isReachable
to true: 当我尝试在禁用防火墙的Windows中使用此代码时,我获取主机名并且
isReachable
为true:
InetAddress addrs = null;
try {
addrs = InetAddress.getByName("192.168.1.1");
System.out.println(addrs.getHostName());
System.out.println(addrs.isReachable(100));
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
But activating firewall I get false
, I can use policy for this? 但是激活防火墙我
false
,我可以使用这个策略吗?
You must configure the firewall to allow for the JVM ( java.exe
) to open connections. 您必须配置防火墙以允许JVM(
java.exe
)打开连接。 The java code does not need to change, it is a configuration issue. java代码不需要更改,这是一个配置问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.