W
weilai2570019
Unregistered / Unconfirmed
GUEST, unregistred user!
string hostname = Dns.GetHostName();//服务器的用户名
IPAddress[] address = Dns.GetHostAddresses(hostname);//获取服务器端IP列表,第一IP是address[0]
IPEndPoint ipendpoint = new IPEndPoint(address[0], 1234);
string pstr = "";
pstr = ipendpoint.Address.ToString();
str = pstr.Split(Convert.ToChar(".");
for (int i = 0;
i < str.Length;
i++)
{
switch (i)
{
case 0:
ip1 = Convert.ToInt32(str);
break;
case 1:
ip2 = Convert.ToInt32(str);
break;
case 2:
ip3 = Convert.ToInt32(str);
break;
case 3:
ip4 = Convert.ToInt32(str);
break;
}
}
yhip = Convert.ToString(ip1) + "."
+ Convert.ToString(ip2) + "."
+ Convert.ToString(ip3) + "."
+ Convert.ToString(ip4);
Response.Write(yhip);
为什么这样获得的还是局域网ip地址亚
IPAddress[] address = Dns.GetHostAddresses(hostname);//获取服务器端IP列表,第一IP是address[0]
IPEndPoint ipendpoint = new IPEndPoint(address[0], 1234);
string pstr = "";
pstr = ipendpoint.Address.ToString();
str = pstr.Split(Convert.ToChar(".");
for (int i = 0;
i < str.Length;
i++)
{
switch (i)
{
case 0:
ip1 = Convert.ToInt32(str);
break;
case 1:
ip2 = Convert.ToInt32(str);
break;
case 2:
ip3 = Convert.ToInt32(str);
break;
case 3:
ip4 = Convert.ToInt32(str);
break;
}
}
yhip = Convert.ToString(ip1) + "."
+ Convert.ToString(ip2) + "."
+ Convert.ToString(ip3) + "."
+ Convert.ToString(ip4);
Response.Write(yhip);
为什么这样获得的还是局域网ip地址亚