First, it’s important to understand that these are shells of the UNIX socket library that provides functions inet_aton(equivalent IPAddress.Parse), gethostbyname(wrapped Dns.GetHostByName), and gethostbyaddr(wrapped Dns.GetHostByAddress). Subsequently, Microsoft added to their Dns.GetHostEntryutility function Dns.GetHostEntry.
Dns.GetHostByName Dns.GetHostByName Dns.GetHostEntry, , Microsoft , API, DNS, DNS.
UNIX gethostbyname IP-, . IP-, , . IPv4. getaddrinfo, , , , , IPv4.
Microsoft . - GetHostByName , , , , DNS, . , , , GetHostEntry , DNS, GetHostEntry , . , GetHostEntry, DNS, IP- GetHostEntry, DNS. , DNS-, , , , , - .
, , GetHostEntry , , IP-, , , IP-, , , . GetHostByName - , , Microsoft . , , " ", @Faisai Mansoor GetHostByName:
if (IPAddress.TryParse(hostName, out address))
return Dns.GetUnresolveAnswer(address);
else
return Dns.InternalGetHostByName(hostName, false);
Dns Dns, , :
if (!IPAddress.TryParse(userInput, out var addressToWhichToConnect))
addressToWhichToConnect = Dns.GetHostEntry(userInput).AddressList.First();