简体   繁体   中英

Why this hostname looks so strange?

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM