J
John J. Hughes II
I have an application that uses a socket. One of the users was complaining
that it would not work if they put the computer name in but only worked if
they put the IP address in. I had them run the below test program and the
problem was the first IP address is not valid. Obviously I need to do
better checking but does anybody have a clue why such an address would come
back anyway?
CODE:
string HostName = System.Net.Dns.GetHostName();
Console.WriteLine("Host Name: " + HostName);
System.Net.IPHostEntry ipHostInfo = System.Net.Dns.GetHostEntry(HostName);
foreach (System.Net.IPAddress ipAddress in ipHostInfo.AddressList)
Console.WriteLine(string.Format("IP Address: {0}", ipAddress));
OUTPUT:
C:\>iptest
Host Name: DELL
IP Address: ::1 <---- what is this and why????
IP Address: 192.168.1.7
Regards,
John
that it would not work if they put the computer name in but only worked if
they put the IP address in. I had them run the below test program and the
problem was the first IP address is not valid. Obviously I need to do
better checking but does anybody have a clue why such an address would come
back anyway?
CODE:
string HostName = System.Net.Dns.GetHostName();
Console.WriteLine("Host Name: " + HostName);
System.Net.IPHostEntry ipHostInfo = System.Net.Dns.GetHostEntry(HostName);
foreach (System.Net.IPAddress ipAddress in ipHostInfo.AddressList)
Console.WriteLine(string.Format("IP Address: {0}", ipAddress));
OUTPUT:
C:\>iptest
Host Name: DELL
IP Address: ::1 <---- what is this and why????
IP Address: 192.168.1.7
Regards,
John