Networking
System
[00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ]
1.0.x.x
1.0.5000.0
2.0.0.0
4.0.0.0
All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.
System.Object
The class is a static class that retrieves information about a specific host from the Internet Domain Name System (DNS).
The host information from the DNS query is returned in an instance of the class. If the specified host has more than one entry in the DNS database, contains multiple IP addresses and aliases.
Provides simple domain name resolution functionality.
Method
2.0.0.0
4.0.0.0
System.IAsyncResult
The method asynchronously queries a DNS server for the IP addresses that are associated with a host name. If is an IP address, this address is returned without querying the DNS server.
This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
When an empty string is passed as the host name, this method returns the IPv4 addresses of the local host for all operating systems except Windows Server 2003; for Windows Server 2003, both IPv4 and IPv6 addresses for the local host are returned.
The asynchronous operation must be completed by calling the method. Typically, the method is invoked by the delegate.
This method does not block until the operation is complete. To block until the operation is complete, use the method.
For more information about using the asynchronous programming model, see Asynchronous Programming Overview
Asynchronously returns the Internet Protocol (IP) addresses for the specified host.
An instance that references the asynchronous request.
The host name or IP address to resolve.
An delegate that references the method to invoke when the operation is complete.
A user-defined object that contains information about the operation. This object is passed to the delegate when the operation is complete.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Obsolete("Use BeginGetHostEntry instead")
System.IAsyncResult
is .
An error was encountered executing the DNS query .
The caller does not have permission to access DNS information.
Requires unrestricted permission for accessing DNS information. See and .
The asynchronous operation must be completed by calling the method. Typically, the method is invoked by the delegate.
This method does not block until the operation is complete. To block until the operation is complete, use the method.
For detailed information about using the asynchronous programming model, see Asynchronous Programming Overview.
This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
Begins an asynchronous request for information about the specified DNS host name.
An instance that references the asynchronous request.
The DNS name of the host.
An delegate that references the method to invoke when the operation is complete.
A user-defined object that contains information about the operation. This object is passed to the delegate when the operation is complete.
0
Method
2.0.0.0
4.0.0.0
System.IAsyncResult
The method asynchronously queries a DNS server for the IP addresses and aliases associated with an IP address.
Note This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
The asynchronous operation must be completed by calling the method. Typically, the method is invoked by the delegate.
This method does not block until the operation is complete. To block until the operation is complete, use the method.
For detailed information about using the asynchronous programming model, see Asynchronous Programming Overview
Asynchronously resolves an IP address to an instance.
An instance that references the asynchronous request.
The IP address to resolve.
An delegate that references the method to invoke when the operation is complete.
A user-defined object that contains information about the operation. This object is passed to the delegate when the operation is complete.
Method
2.0.0.0
4.0.0.0
System.IAsyncResult
The method queries a DNS server for the IP address that is associated with a host name or IP address.
Note This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
The asynchronous operation must be completed by calling the method. Typically, the method is invoked by the delegate.
This method does not block until the operation is complete. To block until the operation is complete, use the method.
For detailed information about using the asynchronous programming model, see Asynchronous Programming Overview.
Asynchronously resolves a host name or IP address to an instance.
An instance that references the asynchronous request.
The host name or IP address to resolve.
An delegate that references the method to invoke when the operation is complete.
A user-defined object that contains information about the operation. This object is passed to the delegate when the operation is complete.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Obsolete("Use BeginGetHostEntry instead")
System.IAsyncResult
is .
An error was encountered executing the DNS query .
The caller does not have permission to access DNS information.
Requires unrestricted permission for accessing DNS information. See and .
The asynchronous operation must be completed by calling the method. Typically, the method is invoked by the delegate.
This method does not block until the operation is complete. To block until the operation is complete, use the method.
For more information about using the asynchronous programming model, see Asynchronous Programming Overview.
This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
Begins an asynchronous request to resolve a DNS host name or IP address to an instance.
An instance that references the asynchronous request.
The DNS name of the host.
An delegate that references the method to invoke when the operation is complete.
A user-defined object that contains information about the operation. This object is passed to the delegate when the operation is complete.
0
Method
2.0.0.0
4.0.0.0
System.Net.IPAddress[]
The method queries a DNS server for the IP addresses associated with a host name. If is an IP address, this address is returned without querying the DNS server.
When an empty string is passed as the host name, this method returns the IPv4 addresses of the local host for all operating systems except Windows Server 2003; for Windows Server 2003, both IPv4 and IPv6 addresses for the local host are returned.
This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
Ends an asynchronous request for DNS information.
An array of type that holds the IP addresses for the host specified by the parameter of .
An instance returned by a call to the method.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Obsolete("Use EndGetHostEntry instead")
System.Net.IPHostEntry
is .
This method blocks until the operation is complete.
To perform this operation synchronously, use the method.
If the property is set to true, the property of the instance returned is not populated by this method and will always be empty.
This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
Ends an asynchronous request for DNS information.
An object that contains DNS information about a host.
An instance that is returned by a call to the method.
0
Method
2.0.0.0
4.0.0.0
System.Net.IPHostEntry
This method blocks until the operation is complete.
The property of the instance returned is not populated by this method and will always be empty.
To perform this operation synchronously, use a method.
This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
Ends an asynchronous request for DNS information.
An instance that contains address information about the host.
An instance returned by a call to an method.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Obsolete("Use EndGetHostEntry instead")
System.Net.IPHostEntry
is .
This method blocks until the operation is complete.
If the is set to true, the property of the instance returned is not populated by this method and will always be empty.
To perform this operation synchronously, use the method.
This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
Ends an asynchronous request for DNS information.
An object that contains DNS information about a host.
An instance that is returned by a call to the method.
0
Method
2.0.0.0
4.0.0.0
System.Net.IPAddress[]
The method queries a DNS server for the IP addresses associated with a host name. If is an IP address, this address is returned without querying the DNS server.
When an empty string is passed as the host name, this method returns the IPv4 addresses of the local host for all operating systems except Windows Server 2003; for Windows Server 2003, both IPv4 and IPv6 addresses for the local host are returned.
IPv6 addresses are filtered from the results of the method if the local computer does not have IPv6 installed. As a result, it is possible to get back an empty instance if only IPv6 results where available for the .parameter.
This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
Returns the Internet Protocol (IP) addresses for the specified host.
An array of type that holds the IP addresses for the host that is specified by the parameter.
The host name or IP address to resolve.
Method
4.0.0.0
System.Threading.Tasks.Task<System.Net.IPAddress[]>
This operation will not block. The returned object will complete after the has been resolved.
This method queries a DNS server for the IP addresses associated with a host name. If is an IP address, this address is returned without querying the DNS server.
Returns the Internet Protocol (IP) addresses for the specified host as an asynchronous operation.
Returns .
The task object representing the asynchronous operation. The property on the task object returns an array of type that holds the IP addresses for the host that is specified by the parameter.
The host name or IP address to resolve.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Obsolete("Use GetHostEntry instead")
System.Net.IPHostEntry
is .
An error was encountered executing the DNS query .
The caller does not have permission to access DNS information.
Requires unrestricted permission for accessing DNS information. See and .
This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
Creates an instance from the specified .
An .
An instance.
An .
0
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Obsolete("Use GetHostEntry instead")
System.Net.IPHostEntry
is .
is not a valid IP address.
An error was encountered executing the DNS query .
The caller does not have permission to access DNS information.
Requires unrestricted permission for accessing DNS information. See and .
This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
Creates an instance from an IP address.
An instance.
An IP address.
0
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Obsolete("Use GetHostEntry instead")
System.Net.IPHostEntry
is .
An error was encountered executing the DNS query .
The caller does not have permission to access DNS information.
Requires unrestricted permission for accessing DNS information. See and .
The method queries the Internet DNS server for host information. If you pass an empty string as the host name, this method retrieves the standard host name for the local computer.
For asynchronous access to DNS information, use the and methods.
If the property is set to true, the property of the instance returned is not populated by this method and will always be empty.
This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
Gets the DNS information for the specified DNS host name.
An object that contains host information for the address specified in .
The DNS name of the host.
0
Method
2.0.0.0
4.0.0.0
System.Net.IPHostEntry
The method queries a DNS server for the IP addresses and aliases associated with an IP address.
IPv6 addresses are filtered from the results of the method if the local computer does not have IPv6 installed. As a result, it is possible to get back an empty instance if only IPv6 results where available for the parameter.
The property of the instance returned is not populated by this method and will always be empty.
This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
Resolves an IP address to an instance.
An instance that contains address information about the host specified in .
An IP address.
Method
2.0.0.0
4.0.0.0
System.Net.IPHostEntry
The method queries a DNS server for the IP address that is associated with a host name or IP address.
When an empty string is passed as the host name, this method returns the IPv4 addresses of the local host.
If the host name could not be found, the exception is returned with a value of 11001 (Windows Sockets error WSAHOST_NOT_FOUND). This exception can be returned if the DNS server does not respond. This exception can also be returned if the name is not an official host name or alias, or it cannot be found in the database(s) being queried.
The exception is also returned if the parameter contains or .
The method assumes that if an IP literal string is passed in the parameter that the application wants an instance returned with all of the properties set. These properties include the , , and . As a result, the implementation of the method exhibits the following behavior when an IP string literal is passed:
-
The method tries to parse the address. If the parameter contains a legal IP string literal, then the first phase succeeds.
-
A reverse lookup using the IP address of the IP string literal is attempted to obtain the host name. This result is set as the property.
-
The host name from this reverse lookup is used again to obtain all the possible IP addresses associated with the name and set as the property.
For an IPv4 string literal, all three steps above may succeed. But it is possible for a stale DNS record for an IPv4 address that actually belongs to a different host to be returned. This may cause step #3 to fail and throw an exception (there is a DNS PTR record for the IPv4 address, but no DNS A record for the IPv4 address).
For IPv6, step #2 above may fail, since most IPv6 deployments do not register the reverse (PTR) record for an IPv6 address. So this method may return the string IPv6 literal as the fully-qualified domain (FQDN) host name in the property.
The method has different behavior with respect to IP literals. If step #1 above succeeds (it successfully parses as an IP address), that address is immediately returned as the result. There is no attempt at a reverse lookup.
IPv6 addresses are filtered from the results of the method if the local computer does not have IPv6 installed. As a result, it is possible to get back an empty instance if only IPv6 results where available for the .parameter.
The property of the instance returned is not populated by this method and will always be empty.
This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
Resolves a host name or IP address to an instance.
An instance that contains address information about the host specified in .
The host name or IP address to resolve.
Method
4.0.0.0
System.Threading.Tasks.Task<System.Net.IPHostEntry>
This operation will not block. The returned object will complete after the has been resolved.
This method queries a DNS server for the IP addresses and aliases associated with an IP address.
IPv6 addresses are filtered from the results of this method if the local computer does not have IPv6 installed. As a result, it is possible to get back an empty instance if only IPv6 results where available for the parameter.
The property of the instance returned is not populated by this method and will always be empty.
This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
Resolves an IP address to an instance as an asynchronous operation.
Returns .
The task object representing the asynchronous operation. The property on the task object returns an instance that contains address information about the host specified in .
An IP address.
Method
4.0.0.0
System.Threading.Tasks.Task<System.Net.IPHostEntry>
This operation will not block. The returned object will complete after the has been resolved.
This method queries a DNS server for the IP address that is associated with a host name or IP address.
When an empty string is passed as the host name, this method returns the IPv4 addresses of the local host.
If the host name could not be found, the exception is returned with a value of 11001 (Windows Sockets error WSAHOST_NOT_FOUND). This exception can be returned if the DNS server does not respond. This exception can also be returned if the name is not an official host name or alias, or it cannot be found in the database(s) being queried.
The exception is also returned if the parameter contains or .
This method assumes that if an IP literal string is passed in the parameter that the application wants an instance returned with all of the properties set. These properties include the , , and . As a result, the implementation of this method exhibits the following behavior when an IP string literal is passed:
-
The method tries to parse the address. If the parameter contains a legal IP string literal, then the first phase succeeds.
-
A reverse lookup using the IP address of the IP string literal is attempted to obtain the host name. This result is set as the property.
-
The host name from this reverse lookup is used again to obtain all the possible IP addresses associated with the name and set as the property.
For an IPv4 string literal, all three steps above may succeed. But it is possible for a stale DNS record for an IPv4 address that actually belongs to a different host to be returned. This may cause step #3 to fail and throw an exception (there is a DNS PTR record for the IPv4 address, but no DNS A record for the IPv4 address).
For IPv6, step #2 above may fail, since most IPv6 deployments do not register the reverse (PTR) record for an IPv6 address. So this method may return the string IPv6 literal as the fully-qualified domain (FQDN) host name in the property.
The method has different behavior with respect to IP literals. If step #1 above succeeds (it successfully parses as an IP address), that address is immediately returned as the result. There is no attempt at a reverse lookup.
IPv6 addresses are filtered from the results of this method if the local computer does not have IPv6 installed. As a result, it is possible to get back an empty instance if only IPv6 results where available for the .parameter.
The property of the instance returned is not populated by this method and will always be empty.
This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
Resolves a host name or IP address to an instance as an asynchronous operation.
Returns .
The task object representing the asynchronous operation. The property on the task object returns an instance that contains address information about the host specified in .
The host name or IP address to resolve.
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.String
To be added.
An error was encountered resolving the local host name.
The caller does not have permission to access DNS information.
Requires unrestricted permission for accessing DNS information. See and .
Gets the host name of the local computer.
A string that contains the DNS host name of the local computer.
0
Method
1.0.5000.0
2.0.0.0
4.0.0.0
System.Obsolete("Use GetHostEntry instead")
System.Net.IPHostEntry
is .
An error was encountered executing the DNS query .
The caller does not have permission to access DNS information.
Requires unrestricted permission for accessing DNS information. This method also asserts unrestricted . See and .
The following example demonstrates the use of the method.
using System;
using System.Net;
public class DnsTest {
public static void Main() {
IPHostEntry hostInfo1 = Dns.Resolve("www.contoso.com");
DisplayHostInfo(hostInfo1);
Console.WriteLine();
}
public static void DisplayHostInfo(IPHostEntry hostInfo) {
string[] aliases = hostInfo.Aliases;
IPAddress[] addresses = hostInfo.AddressList;
Console.WriteLine("The host name is: {0}", hostInfo.HostName);
for(int x = 0; x < aliases.Length; x++)
Console.WriteLine("Alias {0} == {1}", aliases[x], addresses[x]);
}
}
The output is
The host name is: contoso.com
Alias www.contoso.com == 207.46.230.186
The method queries a DNS server for the IP address associated with a host name or IP address.
When is a DNS-style host name associated with multiple IP addresses, only the first IP address that resolves to that host name is returned.
If the property is set to true, the property of the instance returned is not populated by this method and will always be empty.
This member emits trace information when you enable network tracing in your application. For more information, see Network Tracing.
Resolves a DNS host name or IP address to an instance.
An instance that contains address information about the host specified in .
A DNS-style host name or IP address.
0
0