JCIFS、Android 和 getbyname
好吧,尝试了以下代码:
import jcifs.netbios.NbtAddress;
...
try{
NbtAddress addr = NbtAddress.getByName("Base");
}catch (UnknownHostException e){}
...
它抛出了该异常。 有什么想法吗?我已经在 LAN 上的几台指定机器上尝试过
Well, tried the following bit of code:
import jcifs.netbios.NbtAddress;
...
try{
NbtAddress addr = NbtAddress.getByName("Base");
}catch (UnknownHostException e){}
...
And it throws that exception.
Any ideas? I have tried it with a couple of named machines on the LAN
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题在于,NBT 名称解析通过在 LAN 上发送 UDP 广播数据包来工作,而模拟器位于其自己的虚拟 LAN 上,仅通过虚拟 NAT 路由器连接到主机 PC。广播数据包不会在不同子网之间交叉,因此 LAN 上的任何内容都看不到名称查询。
我有同样的问题。据我所知,解决这个问题的唯一想法是:
或者
如果可以在模拟器上运行一些可以用作 NetBIOS 主浏览器的东西,可能还有第三种解决方案,但我还没有对此进行足够的研究。
LMHOSTS 解决方案并不理想,因为您(据我所知)无法浏览工作组和主机。这应该适用于 WINS 服务器,但我还没有尝试过。
The problem is that NBT name resolution works by sending UDP broadcast packets on the LAN, and the emulator lives on its own virtual LAN, connected to your host PC only by a virtual NAT router. Broadcast packets don't cross between different subnets, so nothing on your LAN sees the name query.
I have the same problem. The only ideas for solving it that I know are:
or,
If it was possible to run something on the emulator that could serve as a NetBIOS Master Browser, there might be a third solution, but I haven't researched that enough yet.
The LMHOSTS solution isn't ideal, because you don't (AFAIK) get to browse for workgroups and hosts. That should work with a WINS server, but I haven't tried it.
我用的是模拟器。
当我在真实硬件上运行该应用程序时,问题就消失了。
I was using the emulator.
When I ran the app on real hardware the problem disappeared.
我猜你的清单中没有互联网权限?
I guess you don't have the INTERNET permission in your manifest?