相关疑难解决方法(0)

如何从IP地址解析网络主机名

我工作的基于WiFi聊天引擎,我能够通过跟随着检索连接到当前的wifi网络主机列表这个链接现在得到了与IP地址的设备列表中,但我需要从IP地址的主机名和尝试以下

InetAddress inetAddr;
try {
    inetAddr = InetAddress.getByName(host.hostname);
    String hostname = inetAddr.getHostName();
    String canonicalHostname = inetAddr.getCanonicalHostName();
    holder.computerName.setText("Canonical : "+host.hostname);
} catch (Exception e) {
    e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

这里主机名和规范主机名都显示ip地址而不是主机名.

请帮我解决这个问题.

ip android hostname android-networking android-wifi

1
推荐指数
1
解决办法
4383
查看次数

标签 统计

android ×1

android-networking ×1

android-wifi ×1

hostname ×1

ip ×1