TcpConnectionInformation 类

定义

提供有关本地计算机上的传输控制协议 (TCP) 连接的信息。

public ref class TcpConnectionInformation abstract
public abstract class TcpConnectionInformation
type TcpConnectionInformation = class
Public MustInherit Class TcpConnectionInformation
继承
TcpConnectionInformation

示例

以下示例显示活动 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();
            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

注解

TCP 是一种面向连接的可靠协议,用于在网络计算机之间传输数据。 它在 IETF RFC 793 中定义。

构造函数

TcpConnectionInformation()

初始化 TcpConnectionInformation 类的新实例。

属性

LocalEndPoint

获取传输控制协议 (TCP) 连接的本地终结点。

RemoteEndPoint

获取传输控制协议 (TCP) 连接的远程终结点。

State

获取此传输控制协议 (TCP) 连接的状态。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于