为什么这个主机名看起来这么奇怪?
我使用 DNSSD.resolve() 方法来获取有关 Bonjour 找到的服务的信息。我能够获取找到的服务的端口及其主机名。但是,主机名看起来并不符合我的预期。我以为它是一个 IP 地址,但它等于 ID00926.local.
。那是什么?我可以使用它作为 IP 地址在 Java 中创建套接字吗?
I use DNSSD.resolve() method to get information about a service found by Bonjour. I was able to get the port of the found service as well as its hostname. However, the hostname looks not as I expected. I thought it will be an IP address but it is equal to ID00926.local.
. What is that? Can I use it as an IP address to create sockets in Java?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来您正在获得某种本地定义的主机名,如果您位于公司网络上,则可以在本地 DNS 中获得,也可以在主机文件中获得。
查看名称是否正确解析的最简单方法是尝试对其进行 ping 操作,如果有效,则可以使用它。
不幸的是,我不熟悉 Java,所以其他人必须填写这些详细信息,但我假设您必须首先进行一些名称查找,以便获取要传递到套接字的 IP 地址。
It looks like you are getting some kind of locally defined host name, either in a local DNS if you are on a corporate network, or maybe in the host file.
The easiest way to see that the name resolves correctly is to try to ping it, if it works, then you can use it.
Unfortunately I am not familiar with Java, so someone else will have to fill in on those details, but I assume you have to do some name lookup first in order to get an IP address to pass to the socket.
DNSSD.register()
使用提供的主机名和端口号注册您的服务名称、类型和协议。需要第二步将主机名解析为地址。如果您不提供要注册的主机名,它将使用定义的主机名。如果没有定义的主机名,则会创建一个。这很可能就是发生的事情。DNSSD.register()
registers your service name, type, and protocol using the provided host name and port number. A second step is needed to resolve the host name into an address. If you don't provide the host name to register, it uses the defined host name. If there is no defined host name, then one is created. That's likely what happened.