IP is a common application of the Internet, allowing different hosts to find each other's addressing protocol. The IP address consists of a number of 4 decimal digits, the value of each number is between 0~255, although it solves the problem of computer identification on the network, but the IP address is not easy to remember, so the domain Name System (DNS) was developed, it is specifically used to translate the IP address into meaningful text, To facilitate the identification of memory.
The. Net Framework class library has built-in problems with the related classes for handling IP addresses, which are under the System.Net namespace. The DNS classes are described in detail here. Common methods and descriptions in DNS classes are shown in the table.
Common methods and descriptions of table DNS classes
Name |
Description |
Begingethostaddresses |
Returns an Internet Protocol (IP) address for a specified host asynchronously |
Begingethostbyname |
Starts an asynchronous request for iphostentry information about the specified DNS host name |
Begingethostentry |
has been overloaded. Asynchronously resolves a host name or IP address to a iphostentry instance |
Beginresolve |
Begins an asynchronous request to resolve a DNS host name or IP address to a IPAddress instance |
Endgethostaddresses |
Ending an asynchronous request for DNS information |
Endgethostbyname |
Ending an asynchronous request for DNS information |
Endgethostentry |
Ending an asynchronous request for DNS information |
Endresolve |
Ending an asynchronous request for DNS information |
Gethostaddresses |
Returns the Internet Protocol (IP) address of the specified host |
Gethostbyaddress |
has been overloaded. Obtaining DNS host information for an IP address |
gethostbyname |
Gets DNS information for the specified DNS host name |
GetHostName |
Get the host name of the local computer |
GetType |
Gets the type of the current instance |
Gethostentry |
has been overloaded. Resolves a host name or IP address to a iphostentry instance |
Resolve |
Resolve DNS host name or IP address to iphostentry instance |
The following is a detailed introduction to the more important methods.
(1) Gethostaddresses method
Returns the Internet Protocol (IP) address of the specified host.
Grammar:
public static IPAddress[] GetHostAddresses (
string hostNameOrAddress
)
Parameters:
hostNameOrAddress: The host name or IP address to resolve.
Return value: An array of IPAddress types that holds the IP address of the host specified by the hostNameOrAddress parameter.