[英]How to access host ip address using host pc name in wifi network using android
[英]how to know ip address of a computer by using its pc name in ubuntu
我目前正在處理聊天應用程序。 為了將客戶端連接到服務器,我必須手動輸入服務器的IP地址,因為我們使用的是LAN,每次連接的服務器系統的IP都會更改。 因此,有一種方法可以通過僅使用其PC名稱來查找特定計算機的IP地址。 我目前正在使用Java進行實施。
InetAddress host = InetAddress.getByName("www.java2novice.com");
System.out.println(host.getHostAddress());
此鏈接應該可以為您提供幫助。 http://www.java2novice.com/java_networking/ip_by_host_name/
InetAddress ip = InetAddress.getByName("Host_Name"); // just write the host name of server machine
System.out.println(ip.getHostAddress());
我認為這會對您有所幫助。
如果要獲取Ubuntu PC的唯一IP地址,請鍵入:
$ hostname -I
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.