我们用jcifs 查找局域网计算机通常这样写:
SmbFile[] domains = (new SmbFile("smb://")).listFiles();
但是如果局域网内没有smb服务器,会出现异常:
java.net.UnknownHostException: ..__MSBROWSE__.<01>
at jcifs.netbios.NbtAddress.doNameQuery(NbtAddress.java:317)
at jcifs.netbios.NbtAddress.getByName(NbtAddress.java:422)
at jcifs.netbios.NbtAddress.getByName(NbtAddress.java:403)
at jcifs.smb.SmbFile.getFirstAddress(SmbFile.java:845)
at jcifs.smb.SmbFile.connect(SmbFile.java:946)
at jcifs.smb.SmbFile.connect0(SmbFile.java:875)
at jcifs.smb.SmbFile.doNetServerEnum(SmbFile.java:1907)
at jcifs.smb.SmbFile.doEnum(SmbFile.java:1727)
at jcifs.smb.SmbFile.listFiles(SmbFile.java:1708)
at jcifs.smb.SmbFile.listFiles(SmbFile.java:1641)
at J.main(J.java:10)
下面是老外的答复:
Andre, and anyone else who is listening.
Before working out the bugs in the method you are using, it would be very
beneficial to understand exactly what it is that this method is trying to
accomplish.
It is looking for all nodes within the broadcast domain that are running the
NetBIOS over TCP (NBT) NetBIOS Name Service that are *also* local master
browsers for their workgroup/NT-domain *and* are willing to respond to
broadcast queries.
That was never a reliable way to find all of the nodes on a LAN, and it is
becoming less so as Microsoft phases out use of the NBT transport.
Chris -)-----
原文讨论:
http://samba.2283325.n4.nabble.com/How-to-list-all-computers-in-LAN-td3631970.html
http://lists.samba.org/archive/jcifs/2001-July/000002.html