gpt4 book ai didi

java - avahi 无法找到由 JmDNS 创建的服务

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:25:55 28 4
gpt4 key购买 nike

我正在通过其他运行 windows-xp 的机器创建 JmDNS 服务

JmDNS dns = JmDNS.create("localhost"); 
dns.regesterService("_sreviceTest._tcp.local.", "Test-Service", 8765, "Description");

如果我运行其他将解析服务的客户端,则由 JmDNS 创建并找到它,与机器无关。但是,如果我尝试通过 avahi-browse 查找相同的服务。它找不到它。并给出以下输出。

avahi-browse -rv _sreviceTest._tcp
Server version: avahi 0.6.30; Host name: ubuntu.local
E Ifce Prot Name Type Domain
+ eth0 IPv4 Test-Service _sreviceTest._tcp local
Failed to resolve service 'Test-Service' of type '_serviceTest._tcp' in domain 'local': Timeout reached

最佳答案

这是 JmDNS version 3.4.1 库中的错误。详见BUG

this.service_type = "_ros-master._tcp.local.";
this.service_name = "RosMaster";
this.service_port = 8888;
String service_key = "description"; // Max 9 chars
String service_text = "Hypothetical ros master";
HashMap<String, byte[]> properties = new HashMap<String, byte[]>();
properties.put(service_key, text.getBytes());
// service_info = ServiceInfo.create(service_type, service_name, service_port); // case 1, no text
// service_info = ServiceInfo.create(service_type, service_name, service_port, 0, 0, true, service_text); // case 2, textual description
service_info = ServiceInfo.create(service_type, service_name, service_port, 0, 0, true, properties); // case 3, properties assigned textual description
jmdns.registerService(service_info);

Case 1 and case 2 create services detectable by avahi, but they fail to resolve.
Case 3 works fine.

关于java - avahi 无法找到由 JmDNS 创建的服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12726801/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com