TcpConnectionInformation.LocalEndPoint 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得傳輸控制通訊協定 (TCP) 連線的本機端點。
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
屬性值
IPEndPoint 執行個體,包含本機電腦上的 IP 位址和連接埠。
範例
下列範例會顯示作用中 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