Android 上的域 InetAddress.getAllByName 与 chrome
我有一个类似于 myservice
的主机别名,它被解析为 myservice.mydomain.tld
。
我想自己做ip地址解析;我尝试在 Android 应用程序中调用 InetAddress.getAllByName("myservice")
但抛出 UnknownHostException
。一般解析有效,调用 InetAddress.getAllByName("myservice.mydomain.tld")
返回预期结果。
现在,当我在同一设备上使用 chrome 并浏览 https://myservice
时,chrome 能够解析为导航到 https://myservice
后面的页面。
我尝试从 chromium/chrome 来源 搜索所需的调用,但我只找到了对 <代码> getAllByName 作为android_getaddrinfofornetwork 与记录的相同。
关于 Chrome 等应用程序如何在 Android 上进行 DNS 解析的任何其他提示?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过使用 Network.getAllByName()?看起来这将为您完成主机名解析,然后返回匹配的 InetAddresses
Have you tried using Network.getAllByName()? Looks like that'll do the hostname resolution for you, and then return matching InetAddresses