using System;
using System.Net;
using System.Net.NetworkInformation;
public class Test
{
static string GetFQDN()
{
string domainName = IPGlobalProperties.GetIPGlobalProperties().DomainName;
string hostName = Dns.GetHostName();
if(!hostName.EndsWith(domainName))
{
hostName += "." + domainName;
}
return hostName;
}
public static void Main()
{
Console.WriteLine("GetFQDN() => \"{0}\"", GetFQDN());
Console.WriteLine("GetHostEntry() => \"{0}\"", System.Net.Dns.GetHostEntry("localhost").HostName);
Console.WriteLine("Resolve() => \"{0}\"", System.Net.Dns.Resolve("localhost").HostName);
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uTmV0Owp1c2luZyBTeXN0ZW0uTmV0Lk5ldHdvcmtJbmZvcm1hdGlvbjsKCnB1YmxpYyBjbGFzcyBUZXN0CnsKICAgIHN0YXRpYyBzdHJpbmcgR2V0RlFETigpCiAgICB7CiAgICAgICAgc3RyaW5nIGRvbWFpbk5hbWUgPSBJUEdsb2JhbFByb3BlcnRpZXMuR2V0SVBHbG9iYWxQcm9wZXJ0aWVzKCkuRG9tYWluTmFtZTsKICAgICAgICBzdHJpbmcgaG9zdE5hbWUgPSBEbnMuR2V0SG9zdE5hbWUoKTsKCiAgICAgICAgaWYoIWhvc3ROYW1lLkVuZHNXaXRoKGRvbWFpbk5hbWUpKQogICAgICAgIHsKICAgICAgICAgICAgaG9zdE5hbWUgKz0gIi4iICsgZG9tYWluTmFtZTsKICAgICAgICB9CgogICAgICAgIHJldHVybiBob3N0TmFtZTsKICAgIH0KCglwdWJsaWMgc3RhdGljIHZvaWQgTWFpbigpCgl7CQkKCSAgICBDb25zb2xlLldyaXRlTGluZSgiR2V0RlFETigpID0+IFwiezB9XCIiLCBHZXRGUUROKCkpOwoJCUNvbnNvbGUuV3JpdGVMaW5lKCJHZXRIb3N0RW50cnkoKSA9PiBcInswfVwiIiwgU3lzdGVtLk5ldC5EbnMuR2V0SG9zdEVudHJ5KCJsb2NhbGhvc3QiKS5Ib3N0TmFtZSk7CgkJQ29uc29sZS5Xcml0ZUxpbmUoIlJlc29sdmUoKSA9PiBcInswfVwiIiwgU3lzdGVtLk5ldC5EbnMuUmVzb2x2ZSgibG9jYWxob3N0IikuSG9zdE5hbWUpOwoKCX0KfQ==