我目前正在开发聊天应用程序。 为了将客户端连接到服务器,我必须手动输入服务器的IP地址,因为我们使用LAN,并且每次连接服务器系统时它都会被更改。 那么有没有办法通过使用其PC名称来查找特定计算机的IP地址。 我目前正在使用Java进行实现。
答案 0 :(得分:0)
$('#txtname').html('something'); // this will put "something" in innerHTML
$('#txtname').val('something'); // this will set the VALUE attribute
// of the input to "something"
此链接应该对您有所帮助。 http://www.java2novice.com/java_networking/ip_by_host_name/
答案 1 :(得分:0)
InetAddress ip = InetAddress.getByName("Host_Name"); // just write the host name of server machine
System.out.println(ip.getHostAddress());
我认为这会对你有帮助。
答案 2 :(得分:0)
如果要获取Ubuntu PC的唯一IP地址,请键入:
$ hostname -I