在win7系统下获取的客户端IP是16位进制数
能获取到像“192.168.1.1”的IP值吗?或者还是需要转换之类的方法。
下面是我获取IP的方法
/// <summary>
/// 获取本机IP
/// </summary>
/// <returns></returns>
private string GetIP()
{
string hostName = Dns.GetHostName(); //得到主机名
IPHostEntry ipEntry = Dns.GetHostEntry(hostName);//得到主机IP
string ip = ipEntry.AddressList[0].ToString();
return ip;
}
我把host文件改成
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# 192.168.1.110 localhost
127.0.0.1 www.template.com
127.0.0.1 www.youxi.com
红色是我修改的部分, 改完之后获取的IP是::1(都是localhost的标识)
这个具体要怎么改?