System.Net.Dns.GetHostEntry C# (CSharp) Метод

GetHostEntry() публичный статический Метод

public static GetHostEntry ( IPAddress address ) : IPHostEntry
address IPAddress
Результат IPHostEntry
        public static IPHostEntry GetHostEntry(IPAddress address)
        {
            if (NetEventSource.IsEnabled) NetEventSource.Enter(null, address);
            NameResolutionPal.EnsureSocketsAreInitialized();

            if (address == null)
            {
                throw new ArgumentNullException(nameof(address));
            }

            if (address.Equals(IPAddress.Any) || address.Equals(IPAddress.IPv6Any))
            {
                throw new ArgumentException(SR.Format(SR.net_invalid_ip_addr, nameof(address)));
            }

            IPHostEntry ipHostEntry = InternalGetHostByAddress(address, true);

            if (NetEventSource.IsEnabled) NetEventSource.Exit(null, ipHostEntry);
            return ipHostEntry;
        } // GetHostEntry

Same methods

Dns::GetHostEntry ( string hostNameOrAddress ) : IPHostEntry

Usage Example

Пример #1
0
    private static IPAddress Resolve(string hostName)
    {
        IPHostEntry he = Dns.GetHostEntry(hostName);

        if (he.AddressList.Length < 1)
        {
            throw new ApplicationException("IPHostEntry.AdressList is empty.");
        }
        return(he.AddressList[0]);
    }
All Usage Examples Of System.Net.Dns::GetHostEntry