[英]How can get get computer hostname in other network segment ?
I can get hostname by ip using the method below: (if we are in the same network segment----in case my IP is 10.167.10.2,other's ip is 10.167.10.5) 我可以使用以下方法通过ip获取主机名:(如果我们位于同一网段中-如果我的IP为10.167.10.2,则其他IP为10.167.10.5)
InetAddress add= InetAddress.getByName(ip); InetAddress add = InetAddress.getByName(ip);
String hostname=add.getHostName(); 字符串hostname = add.getHostName();
but I can't get hostname if the ip in other network segment---in case my IP is 10.167.10.2,other's ip is 10.167.13.5 the return is 10.167.13.5,not the computer's hostname 但是如果其他网段中的IP无法获得主机名-如果我的IP为10.167.10.2,其他IP为10.167.13.5,则返回值为10.167.13.5,而不是计算机的主机名
and when I am using C# ,the class DNS has the methed GetHostByAddress(),I can get every hostname by ip mentioned above using this method. 当我使用C#时,类DNS具有方法GetHostByAddress(),使用此方法,我可以通过上述ip获取每个主机名。
Our computers are in a domain。 I'm using windows XP,JAVA 1.6 How can I get computer hostname in other network segment? 我们的计算机在一个域中。我正在使用Windows XP,JAVA 1.6如何获取其他网段中的计算机主机名? Thank you! 谢谢!
IPHostEntry Example IPHostEntry示例
Try this site 试试这个网站
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.