Dns.GetHostByAddress 메서드

정의

IP 주소에 대한 DNS 호스트 정보를 가져옵니다.Gets DNS host information for an IP address. 이러한 메서드는 이제 사용되지 않습니다.These methods are now obsolete.

오버로드

GetHostByAddress(IPAddress)

지정된 IPHostEntry에서 IPAddress 인스턴스를 만듭니다.Creates an IPHostEntry instance from the specified IPAddress.

GetHostByAddress(String)

IP 주소에서 IPHostEntry 인스턴스를 만듭니다.Creates an IPHostEntry instance from an IP address.

GetHostByAddress(IPAddress)

경고

이 API는 현재 사용되지 않습니다.

지정된 IPHostEntry에서 IPAddress 인스턴스를 만듭니다.Creates an IPHostEntry instance from the specified IPAddress.

public:
 static System::Net::IPHostEntry ^ GetHostByAddress(System::Net::IPAddress ^ address);
[System.Obsolete("Use GetHostEntry instead")]
[System.Obsolete("GetHostByAddress is obsoleted for this type, please use GetHostEntry instead. https://go.microsoft.com/fwlink/?linkid=14202")]
[System.Obsolete("GetHostByAddress is obsoleted for this type, please use GetHostEntry instead. https://go.microsoft.com/fwlink/?linkid=14202")]
public static System.Net.IPHostEntry GetHostByAddress (System.Net.IPAddress address);
static member GetHostByAddress : System.Net.IPAddress -> System.Net.IPHostEntry
Public Shared Function GetHostByAddress (address As IPAddress) As IPHostEntry

매개 변수

address
IPAddress

IPAddress입니다.An IPAddress.

반환

IPHostEntry 인스턴스입니다.An IPHostEntry instance.

특성

예외

addressnull입니다.address is null.

address을 확인할 때 오류가 발생한 경우An error is encountered when resolving address.

예제

다음 예에서는 IPAddress에서 IPHostEntry를 만듭니다.The following example creates a IPHostEntry from an IPAddress.

try
{
   IPAddress^ hostIPAddress = IPAddress::Parse( IpAddressString );
   IPHostEntry^ hostInfo = Dns::GetHostByAddress( hostIPAddress );
   
   // Get the IP address list that resolves to the host names contained in
   // the Alias property.
   array<IPAddress^>^address = hostInfo->AddressList;
   
   // Get the alias names of the addresses in the IP address list.
   array<String^>^alias = hostInfo->Aliases;
   Console::WriteLine( "Host name : {0}", hostInfo->HostName );
   Console::WriteLine( "\nAliases :" );
   for ( int index = 0; index < alias->Length; index++ )
      Console::WriteLine( alias[ index ] );
   Console::WriteLine( "\nIP address list : " );
   for ( int index = 0; index < address->Length; index++ )
      Console::WriteLine( address[ index ] );
}
catch ( SocketException^ e ) 
{
   Console::WriteLine( "SocketException caught!!!" );
   Console::WriteLine( "Source : {0}", e->Source );
   Console::WriteLine( "Message : {0}", e->Message );
}
catch ( FormatException^ e ) 
{
   Console::WriteLine( "FormatException caught!!!" );
   Console::WriteLine( "Source : {0}", e->Source );
   Console::WriteLine( "Message : {0}", e->Message );
}
catch ( ArgumentNullException^ e ) 
{
   Console::WriteLine( "ArgumentNullException caught!!!" );
   Console::WriteLine( "Source : {0}", e->Source );
   Console::WriteLine( "Message : {0}", e->Message );
}
catch ( Exception^ e ) 
{
   Console::WriteLine( "Exception caught!!!" );
   Console::WriteLine( "Source : {0}", e->Source );
   Console::WriteLine( "Message : {0}", e->Message );
}
 try 
 {
    IPAddress hostIPAddress = IPAddress.Parse(IpAddressString);
    IPHostEntry hostInfo = Dns.GetHostByAddress(hostIPAddress);
    // Get the IP address list that resolves to the host names contained in 
    // the Alias property.
    IPAddress[] address = hostInfo.AddressList;
    // Get the alias names of the addresses in the IP address list.
    String[] alias = hostInfo.Aliases;

    Console.WriteLine("Host name : " + hostInfo.HostName);
    Console.WriteLine("\nAliases :");
    for(int index=0; index < alias.Length; index++) {
      Console.WriteLine(alias[index]);
    } 
    Console.WriteLine("\nIP address list : ");
    for(int index=0; index < address.Length; index++) {
       Console.WriteLine(address[index]);
    }
 }
 catch(SocketException e) 
 {
Console.WriteLine("SocketException caught!!!");
    Console.WriteLine("Source : " + e.Source);
    Console.WriteLine("Message : " + e.Message);
 }
 catch(FormatException e)
 {
Console.WriteLine("FormatException caught!!!");
    Console.WriteLine("Source : " + e.Source);
    Console.WriteLine("Message : " + e.Message);
 }
 catch(ArgumentNullException e)
 {
Console.WriteLine("ArgumentNullException caught!!!");
    Console.WriteLine("Source : " + e.Source);
    Console.WriteLine("Message : " + e.Message);
 }
 catch(Exception e)
 {
     Console.WriteLine("Exception caught!!!");
     Console.WriteLine("Source : " + e.Source);
     Console.WriteLine("Message : " + e.Message);
 }
Public Sub DisplayHostAddress(IpAddressString As [String])
    Try
        Dim hostIPAddress As IPAddress = IPAddress.Parse(IpAddressString)
        
        ' Call the GetHostByAddress(IPAddress) method, passing an IPAddress object as an argument 
        ' to obtain an IPHostEntry instance, containing address information for the specified host.
        
        Dim hostInfo As IPHostEntry = Dns.GetHostByAddress(hostIPAddress)
        ' Get the IP address list that resolves to the host names contained in 
        ' the Alias property.
        Dim address As IPAddress() = hostInfo.AddressList
        ' Get the alias names of the above addresses in the IP address list.
        Dim [alias] As [String]() = hostInfo.Aliases
        
        Console.WriteLine(("Host name : " + hostInfo.HostName))
        Console.WriteLine(ControlChars.Cr + "Aliases :")
        Dim index As Integer
        For index = 0 To [alias].Length - 1
            Console.WriteLine([alias](index))
        Next index
        Console.WriteLine(ControlChars.Cr + "IP address list : ")

        For index = 0 To address.Length - 1
            Console.WriteLine(address(index))
        Next index
        
    Catch e As SocketException
        Console.WriteLine("SocketException caught!!!")
        Console.WriteLine(("Source : " + e.Source))
        Console.WriteLine(("Message : " + e.Message))
        
    Catch e As FormatException
        Console.WriteLine("FormatException caught!!!")
        Console.WriteLine(("Source : " + e.Source))
        Console.WriteLine(("Message : " + e.Message))
        
    Catch e As ArgumentNullException
        Console.WriteLine("ArgumentNullException caught!!!")
        Console.WriteLine(("Source : " + e.Source))
        Console.WriteLine(("Message : " + e.Message))
        
    Catch e As Exception
        Console.WriteLine("Exception caught!!!")
        Console.WriteLine(("Source : " + e.Source))
        Console.WriteLine(("Message : " + e.Message))
    End Try
End Sub

설명

참고

이 멤버는 애플리케이션에서 네트워크 추적을 사용 하도록 설정 하면 추적 정보를 내보냅니다.This member emits trace information when you enable network tracing in your application. 자세한 내용은 .NET Framework의 네트워크 추적합니다.For more information, see Network Tracing in the .NET Framework.

보안

DnsPermission
DNS 정보에 액세스 합니다.for accessing DNS information. 연결 된 열거형: UnrestrictedAssociated enumeration: Unrestricted

GetHostByAddress(String)

경고

이 API는 현재 사용되지 않습니다.

IP 주소에서 IPHostEntry 인스턴스를 만듭니다.Creates an IPHostEntry instance from an IP address.

public:
 static System::Net::IPHostEntry ^ GetHostByAddress(System::String ^ address);
[System.Obsolete("Use GetHostEntry instead")]
[System.Obsolete("GetHostByAddress is obsoleted for this type, please use GetHostEntry instead. https://go.microsoft.com/fwlink/?linkid=14202")]
[System.Obsolete("GetHostByAddress is obsoleted for this type, please use GetHostEntry instead. https://go.microsoft.com/fwlink/?linkid=14202")]
public static System.Net.IPHostEntry GetHostByAddress (string address);
static member GetHostByAddress : string -> System.Net.IPHostEntry
Public Shared Function GetHostByAddress (address As String) As IPHostEntry

매개 변수

address
String

IP 주소입니다.An IP address.

반환

IPHostEntry 인스턴스입니다.An IPHostEntry instance.

특성

예외

addressnull입니다.address is null.

address을 확인할 때 오류가 발생한 경우An error is encountered when resolving address.

address이 유효한 IP 주소가 아닌 경우address is not a valid IP address.

설명

참고

이 멤버는 애플리케이션에서 네트워크 추적을 사용 하도록 설정 하면 추적 정보를 내보냅니다.This member emits trace information when you enable network tracing in your application. 자세한 내용은 .NET Framework의 네트워크 추적합니다.For more information, see Network Tracing in the .NET Framework.

보안

DnsPermission
DNS 정보에 액세스 합니다.for accessing DNS information. 연결 된 열거형: UnrestrictedAssociated enumeration: Unrestricted

적용 대상