在 Linux 终端中,运行以下命令以更新软件包列表和安装 Dnsmasq:
sudo apt update
sudo apt install dnsmasq
2018年11月22日大约 13 分钟
在 Linux 终端中,运行以下命令以更新软件包列表和安装 Dnsmasq:
sudo apt update
sudo apt install dnsmasq
此处展示了 JmDNS 库的一些基本信息和示例代码。
JmDNS 是 Java 中多播 DNS 的实现。它支持服务发现和服务注册,并且与 Apple 的 Bonjour 完全兼容。
import java.io.IOException;
import java.net.InetAddress;
import javax.jmdns.JmDNS;
import javax.jmdns.ServiceInfo;
public class ExampleServiceRegistration {
public static void main(String[] args) throws InterruptedException {
try {
// 创建一个 JmDNS 实例
JmDNS jmdns = JmDNS.create(InetAddress.getLocalHost());
// 注册一个服务
ServiceInfo serviceInfo = ServiceInfo.create("_http._tcp.local.", "example", 1234, "path=index.html");
jmdns.registerService(serviceInfo);
// 等待片刻
Thread.sleep(25000);
// 注销所有服务
jmdns.unregisterAllServices();
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
}