Dns.GetHostAddressesAsync Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
GetHostAddressesAsync(String, AddressFamily, CancellationToken) |
Returns the Internet Protocol (IP) addresses for the specified host as an asynchronous operation. |
GetHostAddressesAsync(String, CancellationToken) |
Returns the Internet Protocol (IP) addresses for the specified host as an asynchronous operation. |
GetHostAddressesAsync(String) |
Returns the Internet Protocol (IP) addresses for the specified host as an asynchronous operation. |
- Source:
- Dns.cs
- Source:
- Dns.cs
- Source:
- Dns.cs
Returns the Internet Protocol (IP) addresses for the specified host as an asynchronous operation.
public static System.Threading.Tasks.Task<System.Net.IPAddress[]> GetHostAddressesAsync (string hostNameOrAddress, System.Net.Sockets.AddressFamily family, System.Threading.CancellationToken cancellationToken = default);
static member GetHostAddressesAsync : string * System.Net.Sockets.AddressFamily * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.IPAddress[]>
Public Shared Function GetHostAddressesAsync (hostNameOrAddress As String, family As AddressFamily, Optional cancellationToken As CancellationToken = Nothing) As Task(Of IPAddress())
Parameters
- hostNameOrAddress
- String
The host name or IP address to resolve.
- family
- AddressFamily
The address family for which IPs should be retrieved. If Unspecified, retrieve all IPs regardless of address family.
- cancellationToken
- CancellationToken
A cancellation token that can be used to signal the asynchronous operation should be canceled.
Returns
The task object representing the asynchronous operation. The Result property on the task object returns an array of type IPAddress that holds the IP addresses for the host that is specified by the hostNameOrAddress
parameter.
Exceptions
The cancellation token was canceled. This exception is stored into the returned task.
Remarks
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by GetHostAddresses(String, AddressFamily).
Applies to
.NET 9 és más verziók
Termék | Verziók |
---|---|
.NET | 6, 7, 8, 9 |
- Source:
- Dns.cs
- Source:
- Dns.cs
- Source:
- Dns.cs
Returns the Internet Protocol (IP) addresses for the specified host as an asynchronous operation.
public:
static System::Threading::Tasks::Task<cli::array <System::Net::IPAddress ^> ^> ^ GetHostAddressesAsync(System::String ^ hostNameOrAddress, System::Threading::CancellationToken cancellationToken);
public static System.Threading.Tasks.Task<System.Net.IPAddress[]> GetHostAddressesAsync (string hostNameOrAddress, System.Threading.CancellationToken cancellationToken);
static member GetHostAddressesAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.IPAddress[]>
Public Shared Function GetHostAddressesAsync (hostNameOrAddress As String, cancellationToken As CancellationToken) As Task(Of IPAddress())
Parameters
- hostNameOrAddress
- String
The host name or IP address to resolve.
- cancellationToken
- CancellationToken
A cancellation token that can be used to signal the asynchronous operation should be canceled.
Returns
The task object representing the asynchronous operation. The Result property on the task object returns an array of type IPAddress that holds the IP addresses for the host that is specified by the hostNameOrAddress
parameter.
Exceptions
The cancellation token was canceled. This exception is stored into the returned task.
Remarks
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by GetHostAddresses(String).
Applies to
.NET 9 és más verziók
Termék | Verziók |
---|---|
.NET | 6, 7, 8, 9 |
- Source:
- Dns.cs
- Source:
- Dns.cs
- Source:
- Dns.cs
Returns the Internet Protocol (IP) addresses for the specified host as an asynchronous operation.
public:
static System::Threading::Tasks::Task<cli::array <System::Net::IPAddress ^> ^> ^ GetHostAddressesAsync(System::String ^ hostNameOrAddress);
public static System.Threading.Tasks.Task<System.Net.IPAddress[]> GetHostAddressesAsync (string hostNameOrAddress);
static member GetHostAddressesAsync : string -> System.Threading.Tasks.Task<System.Net.IPAddress[]>
Public Shared Function GetHostAddressesAsync (hostNameOrAddress As String) As Task(Of IPAddress())
Parameters
- hostNameOrAddress
- String
The host name or IP address to resolve.
Returns
The task object representing the asynchronous operation. The Result property on the task object returns an array of type IPAddress that holds the IP addresses for the host that is specified by the hostNameOrAddress
parameter.
Exceptions
hostNameOrAddress
is null
.
The length of hostNameOrAddress
is greater than 255 characters.
An error is encountered when resolving hostNameOrAddress
.
hostNameOrAddress
is an invalid IP address.
Remarks
This operation will not block. The returned Task<TResult> object will complete after the hostNameOrAddress
has been resolved.
This method queries a DNS server for the IP addresses associated with a host name. If hostNameOrAddress
is an IP address, this address is returned without querying the DNS server.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by GetHostAddresses(String).
Applies to
.NET 9 és más verziók
Termék | Verziók |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
.NET-visszajelzés
A(z) .NET egy nyílt forráskód projekt. Visszajelzés adásához válasszon egy hivatkozást: