列出 LAN 上所有计算机的名称或 IP [英] Listing name of or ip of all computers on a LAN

查看:32
本文介绍了列出 LAN 上所有计算机的名称或 IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮我列出用JAVA连接到局域网的所有计算机的名称?

Anyone could you please help me to list the name of all computers connected to the LAN with JAVA?

推荐答案

在不使用外部系统调用的情况下解决此问题的一种方法是尝试每个可能的 IP 地址.

One way you could solve this without using outside system calls would be to try every single possible IP address.

遍历地址,使用类似这样的东西向每个地址发送数据......

Iterate over addresses, sending data to each one using something like this...

for (int i =0; i<100; i++) {
    String ip = "192.168.1." + i
    InetAddress address = InetAddress.getByAddress(ip); 
}

您收到的任何回复都表示一个活动 IP.但是,在这种方法中,您将受到子网的限制.

Any responses you get would indicate an active IP. You will be a limited by your subnet in this approach, however.

这篇关于列出 LAN 上所有计算机的名称或 IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆