jcifs 查找局域网计算机

讨论了使用jcifs查找局域网计算机时遇到的UnknownHostException异常问题,解释了异常原因并提供了理解该方法实际操作的重要信息。强调了随着Microsoft减少NBT运输的使用,这种方法变得不可靠。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


我们用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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值