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

System.Net.Dns.GetHostByName Method

Queries DNS for address information about the specified host. [Edit]

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

Parameters

hostName
A string containing the DNS name of the host. [Edit]

Returns

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

Permissions

TypeReason
System.Net.DnsPermission [Edit] Requires unrestricted permission for accessing DNS information. See System.Net.DnsPermission and System.Security.Permissions.PermissionState.Unrestricted.

Exceptions

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

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.

[Edit]

Requirements

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