Dns.BeginGetHostEntry 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
호스트 이름 또는 IP 주소를 IPHostEntry 인스턴스로 비동기적으로 확인합니다.
오버로드
| Name | Description |
|---|---|
| BeginGetHostEntry(IPAddress, AsyncCallback, Object) |
인스턴스에 대한 IP 주소를 IPHostEntry 비동기적으로 확인합니다. |
| BeginGetHostEntry(String, AsyncCallback, Object) |
호스트 이름 또는 IP 주소를 IPHostEntry 인스턴스로 비동기적으로 확인합니다. |
BeginGetHostEntry(IPAddress, AsyncCallback, Object)
- Source:
- Dns.cs
- Source:
- Dns.cs
- Source:
- Dns.cs
- Source:
- Dns.cs
- Source:
- Dns.cs
인스턴스에 대한 IP 주소를 IPHostEntry 비동기적으로 확인합니다.
public:
static IAsyncResult ^ BeginGetHostEntry(System::Net::IPAddress ^ address, AsyncCallback ^ requestCallback, System::Object ^ stateObject);
public static IAsyncResult BeginGetHostEntry(System.Net.IPAddress address, AsyncCallback? requestCallback, object? stateObject);
public static IAsyncResult BeginGetHostEntry(System.Net.IPAddress address, AsyncCallback requestCallback, object stateObject);
static member BeginGetHostEntry : System.Net.IPAddress * AsyncCallback * obj -> IAsyncResult
Public Shared Function BeginGetHostEntry (address As IPAddress, requestCallback As AsyncCallback, stateObject As Object) As IAsyncResult
매개 변수
- address
- IPAddress
확인할 IP 주소입니다.
- requestCallback
- AsyncCallback
AsyncCallback 작업이 완료되면 호출할 메서드를 참조하는 대리자입니다.
- stateObject
- Object
작업에 대한 정보를 포함하는 사용자 정의 개체입니다. 작업이 완료되면 이 개체가 requestCallback 대리자에게 전달됩니다.
반품
IAsyncResult 비동기 요청을 참조하는 인스턴스입니다.
예외
address은 null입니다.
를 확인할 때 오류가 발생합니다 address.
address 가 잘못된 IP 주소입니다.
예제
다음 코드 예제에서는 인스턴스에 BeginGetHostEntry IP 주소를 확인 하는 IPHostEntry 방법을 사용 합니다.
// Signals when the resolve has finished.
public static ManualResetEvent GetHostEntryFinished =
new ManualResetEvent(false);
// Define the state object for the callback.
// Use hostName to correlate calls with the proper result.
public class ResolveState
{
string hostName;
IPHostEntry resolvedIPs;
public ResolveState(string host)
{
hostName = host;
}
public IPHostEntry IPs
{
get { return resolvedIPs; }
set { resolvedIPs = value; }
}
public string host
{
get { return hostName; }
set { hostName = value; }
}
}
// Record the IPs in the state object for later use.
public static void GetHostEntryCallback(IAsyncResult ar)
{
ResolveState ioContext = (ResolveState)ar.AsyncState;
ioContext.IPs = Dns.EndGetHostEntry(ar);
GetHostEntryFinished.Set();
}
// Determine the Internet Protocol (IP) addresses for
// this host asynchronously.
public static void DoGetHostEntryAsync(string hostname)
{
GetHostEntryFinished.Reset();
ResolveState ioContext= new ResolveState(hostname);
Dns.BeginGetHostEntry(ioContext.host,
new AsyncCallback(GetHostEntryCallback), ioContext);
// Wait here until the resolve completes (the callback
// calls .Set())
GetHostEntryFinished.WaitOne();
Console.WriteLine("EndGetHostEntry({0}) returns:", ioContext.host);
foreach (IPAddress address in ioContext.IPs.AddressList)
{
Console.WriteLine($" {address}");
}
}
' Signals when the resolve has finished.
Dim Shared GetHostEntryFinished As ManualResetEvent = New ManualResetEvent(False)
' Define the state object for the callback.
' Use hostName to correlate calls with the proper result.
Class ResolveState
Dim hostName As String
Dim resolvedIPs As IPHostEntry
Public Sub New(host As String)
hostName = host
End Sub
Public Property IPs AS IPHostEntry
Get
Return resolvedIPs
End Get
Set
resolvedIPs = value
End Set
End Property
Public Property host As String
Get
Return hostName
End Get
Set
hostName = value
End Set
End Property
End Class
' Record the IPs in the state object for later use.
Shared Sub GetHostEntryCallback(ar As IAsyncResult)
Dim ioContext As ResolveState = ar.AsyncState
ioContext.IPs = Dns.EndGetHostEntry(ar)
GetHostEntryFinished.Set()
End Sub
' Determine the Internet Protocol (IP) addresses for
' this host asynchronously.
Shared Sub DoGetHostEntryAsync(hostname As String)
GetHostEntryFinished.Reset()
Dim ioContext As ResolveState = New ResolveState(hostname)
Dns.BeginGetHostEntry(ioContext.host,AddressOf GetHostEntryCallback, ioContext)
' Wait here until the resolve completes (the callback
' calls .Set())
GetHostEntryFinished.WaitOne()
Console.WriteLine($"EndGetHostEntry({ioContext.host}) returns:")
Dim addresses As IPAddress() = ioContext.IPs.AddressList
Dim index As Integer
For index = 0 To addresses.Length - 1
Console.WriteLine($" {addresses(index)}")
Next index
End Sub
설명
이 메서드는 BeginGetHostEntry IP 주소와 연결된 IP 주소 및 별칭에 대해 DNS 서버를 비동기적으로 쿼리합니다.
참고 이 멤버는 애플리케이션에서 네트워크 추적을 사용하도록 설정할 때 추적 정보를 내보낸다. 자세한 내용은 .NET Framework의Network 추적 참조하세요.
메서드를 호출 BeginGetHostEntry 하여 비동 EndGetHostEntry 기 작업을 완료해야 합니다. 일반적으로 메서드는 대리자가 호출합니다 requestCallback .
이 메서드는 작업이 완료될 때까지 차단되지 않습니다. 작업이 완료될 때까지 차단하려면 메서드를 GetHostEntry 사용합니다.
비동기 프로그래밍 모델 사용에 대한 자세한 내용은 동기 메서드 비동기 호출을 참조하세요.
적용 대상
BeginGetHostEntry(String, AsyncCallback, Object)
- Source:
- Dns.cs
- Source:
- Dns.cs
- Source:
- Dns.cs
- Source:
- Dns.cs
- Source:
- Dns.cs
호스트 이름 또는 IP 주소를 IPHostEntry 인스턴스로 비동기적으로 확인합니다.
public:
static IAsyncResult ^ BeginGetHostEntry(System::String ^ hostNameOrAddress, AsyncCallback ^ requestCallback, System::Object ^ stateObject);
public static IAsyncResult BeginGetHostEntry(string hostNameOrAddress, AsyncCallback? requestCallback, object? stateObject);
public static IAsyncResult BeginGetHostEntry(string hostNameOrAddress, AsyncCallback requestCallback, object stateObject);
static member BeginGetHostEntry : string * AsyncCallback * obj -> IAsyncResult
Public Shared Function BeginGetHostEntry (hostNameOrAddress As String, requestCallback As AsyncCallback, stateObject As Object) As IAsyncResult
매개 변수
- hostNameOrAddress
- String
확인할 호스트 이름 또는 IP 주소입니다.
- requestCallback
- AsyncCallback
AsyncCallback 작업이 완료되면 호출할 메서드를 참조하는 대리자입니다.
- stateObject
- Object
작업에 대한 정보를 포함하는 사용자 정의 개체입니다. 작업이 완료되면 이 개체가 requestCallback 대리자에게 전달됩니다.
반품
IAsyncResult 비동기 요청을 참조하는 인스턴스입니다.
예외
hostNameOrAddress은 null입니다.
길이 hostNameOrAddress 가 255자를 초과합니다.
를 확인할 때 오류가 발생합니다 hostNameOrAddress.
hostNameOrAddress 가 잘못된 IP 주소입니다.
예제
다음 코드 예제에서는 인스턴스에 BeginGetHostEntry IP 주소를 확인 하는 IPHostEntry 방법을 사용 합니다.
// Signals when the resolve has finished.
public static ManualResetEvent GetHostEntryFinished =
new ManualResetEvent(false);
// Define the state object for the callback.
// Use hostName to correlate calls with the proper result.
public class ResolveState
{
string hostName;
IPHostEntry resolvedIPs;
public ResolveState(string host)
{
hostName = host;
}
public IPHostEntry IPs
{
get { return resolvedIPs; }
set { resolvedIPs = value; }
}
public string host
{
get { return hostName; }
set { hostName = value; }
}
}
// Record the IPs in the state object for later use.
public static void GetHostEntryCallback(IAsyncResult ar)
{
ResolveState ioContext = (ResolveState)ar.AsyncState;
ioContext.IPs = Dns.EndGetHostEntry(ar);
GetHostEntryFinished.Set();
}
// Determine the Internet Protocol (IP) addresses for
// this host asynchronously.
public static void DoGetHostEntryAsync(string hostname)
{
GetHostEntryFinished.Reset();
ResolveState ioContext= new ResolveState(hostname);
Dns.BeginGetHostEntry(ioContext.host,
new AsyncCallback(GetHostEntryCallback), ioContext);
// Wait here until the resolve completes (the callback
// calls .Set())
GetHostEntryFinished.WaitOne();
Console.WriteLine("EndGetHostEntry({0}) returns:", ioContext.host);
foreach (IPAddress address in ioContext.IPs.AddressList)
{
Console.WriteLine($" {address}");
}
}
' Signals when the resolve has finished.
Dim Shared GetHostEntryFinished As ManualResetEvent = New ManualResetEvent(False)
' Define the state object for the callback.
' Use hostName to correlate calls with the proper result.
Class ResolveState
Dim hostName As String
Dim resolvedIPs As IPHostEntry
Public Sub New(host As String)
hostName = host
End Sub
Public Property IPs AS IPHostEntry
Get
Return resolvedIPs
End Get
Set
resolvedIPs = value
End Set
End Property
Public Property host As String
Get
Return hostName
End Get
Set
hostName = value
End Set
End Property
End Class
' Record the IPs in the state object for later use.
Shared Sub GetHostEntryCallback(ar As IAsyncResult)
Dim ioContext As ResolveState = ar.AsyncState
ioContext.IPs = Dns.EndGetHostEntry(ar)
GetHostEntryFinished.Set()
End Sub
' Determine the Internet Protocol (IP) addresses for
' this host asynchronously.
Shared Sub DoGetHostEntryAsync(hostname As String)
GetHostEntryFinished.Reset()
Dim ioContext As ResolveState = New ResolveState(hostname)
Dns.BeginGetHostEntry(ioContext.host,AddressOf GetHostEntryCallback, ioContext)
' Wait here until the resolve completes (the callback
' calls .Set())
GetHostEntryFinished.WaitOne()
Console.WriteLine($"EndGetHostEntry({ioContext.host}) returns:")
Dim addresses As IPAddress() = ioContext.IPs.AddressList
Dim index As Integer
For index = 0 To addresses.Length - 1
Console.WriteLine($" {addresses(index)}")
Next index
End Sub
설명
이 메서드는 BeginGetHostEntry DNS 서버에서 호스트 이름 또는 IP 주소와 연결된 IP 주소를 쿼리합니다.
참고 이 멤버는 애플리케이션에서 네트워크 추적을 사용하도록 설정할 때 추적 정보를 내보낸다. 자세한 내용은 .NET Framework의Network 추적 참조하세요.
메서드를 호출 BeginGetHostEntry 하여 비동 EndGetHostEntry 기 작업을 완료해야 합니다. 일반적으로 메서드는 대리자가 호출합니다 requestCallback .
이 메서드는 작업이 완료될 때까지 차단되지 않습니다. 작업이 완료될 때까지 차단하려면 메서드를 GetHostEntry 사용합니다.
비동기 프로그래밍 모델 사용에 대한 자세한 내용은 동기 메서드를 비동기적으로 호출하는 방법을 참조하세요.