다음을 통해 공유


TcpConnectionInformation.LocalEndPoint 속성

정의

TCP(Transmission Control Protocol) 연결의 로컬 엔드포인트를 가져옵니다.

public:
 abstract property System::Net::IPEndPoint ^ LocalEndPoint { System::Net::IPEndPoint ^ get(); };
public abstract System.Net.IPEndPoint LocalEndPoint { get; }
member this.LocalEndPoint : System.Net.IPEndPoint
Public MustOverride ReadOnly Property LocalEndPoint As IPEndPoint

속성 값

로컬 컴퓨터의 IP 주소 및 포트가 들어 있는 IPEndPoint 인스턴스입니다.

예제

다음은 활성 TCP 연결에 대한 엔드포인트 정보를 표시하는 예제입니다.

void GetTcpConnections()
{
   IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties();
   array<TcpConnectionInformation^>^connections = properties->GetActiveTcpConnections();
   System::Collections::IEnumerator^ myEnum = connections->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      TcpConnectionInformation ^ t = safe_cast<TcpConnectionInformation ^>(myEnum->Current);
      Console::Write( "Local endpoint: {0} ", t->LocalEndPoint->Address );
      Console::Write( "Remote endpoint: {0} ", t->RemoteEndPoint->Address );
      Console::WriteLine( "{0}", t->State );
   }
}
public static void GetTcpConnections()
{
    IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
    TcpConnectionInformation[] connections = properties.GetActiveTcpConnections();

    foreach (TcpConnectionInformation t in connections)
    {
        Console.Write("Local endpoint: {0} ",t.LocalEndPoint.Address);
        Console.Write("Remote endpoint: {0} ",t.RemoteEndPoint.Address);
        Console.WriteLine("{0}",t.State);
    }
    Console.WriteLine();
}
Public Shared Sub GetTcpConnections() 
    Dim properties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
    Dim connections As TcpConnectionInformation() = properties.GetActiveTcpConnections()
    
    Dim t As TcpConnectionInformation
    For Each t In  connections
        Console.Write("Local endpoint: {0} ", t.LocalEndPoint.Address)
        Console.Write("Remote endpoint: {0} ", t.RemoteEndPoint.Address)
        Console.WriteLine("{0}", t.State)
    Next t

End Sub

적용 대상