Mono Class Library: System.Net.Dns Overview | Members

System.Net.Dns.GetHostByName Method

Queries DNS for address information about the specified host.

[System.Obsolete("Use GetHostEntry instead")]
public static IPHostEntry GetHostByName (string hostName)

Parameters

hostName
A string containing the DNS name of the host.

Returns

A System.Net.IPHostEntry object containing host information for the address specified in hostName .

Permissions

TypeReason
System.Net.DnsPermissionRequires unrestricted permission for accessing DNS information. See System.Net.DnsPermission and System.Security.Permissions.PermissionState.Unrestricted.

Exceptions

TypeReason
ArgumentNullExceptionhostName is null .
System.Net.Sockets.SocketExceptionAn error was encountered executing the DNS query .
System.Security.SecurityExceptionThe caller does not have permission to access DNS information.

Remarks

Note:

To retrieve host information asynchronously, use the Dns.BeginGetHostByName(string, AsyncCallback, object) and Dns.EndGetHostByName(IAsyncResult) methods.

See the System.Net.IPHostEntry class page for an example that uses the Dns.GetHostByName(string) method.

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0