IPGlobalProperties.GetTcpIPv4Statistics 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供本機電腦的傳輸控制通訊協定/網際網路通訊協定第 4 版 (TCP/IPv4) 統計資料。
public:
abstract System::Net::NetworkInformation::TcpStatistics ^ GetTcpIPv4Statistics();
public abstract System.Net.NetworkInformation.TcpStatistics GetTcpIPv4Statistics ();
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.TcpStatistics GetTcpIPv4Statistics ();
abstract member GetTcpIPv4Statistics : unit -> System.Net.NetworkInformation.TcpStatistics
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
abstract member GetTcpIPv4Statistics : unit -> System.Net.NetworkInformation.TcpStatistics
Public MustOverride Function GetTcpIPv4Statistics () As TcpStatistics
傳回
TcpStatistics 物件,其提供本機電腦的 TCP/IPv4 流量統計資料。
- 屬性
例外狀況
呼叫 Win32 函式 GetTcpStatistics
失敗。
範例
下列範例會顯示本機計算機的 TCP/IP 統計數據。
void ShowTcpStatistics( NetworkInterfaceComponent version )
{
IPGlobalProperties ^ properties = IPGlobalProperties::GetIPGlobalProperties();
TcpStatistics ^ tcpstat = nullptr;
Console::WriteLine( "" );
switch ( version )
{
case NetworkInterfaceComponent::IPv4:
tcpstat = properties->GetTcpIPv4Statistics();
Console::WriteLine( "TCP/IPv4 Statistics:" );
break;
case NetworkInterfaceComponent::IPv6:
tcpstat = properties->GetTcpIPv6Statistics();
Console::WriteLine( "TCP/IPv6 Statistics:" );
break;
default:
throw gcnew ArgumentException( "version" );
break;
}
Console::WriteLine( " Minimum Transmission Timeout............. : {0}",
tcpstat->MinimumTransmissionTimeout );
Console::WriteLine( " Maximum Transmission Timeout............. : {0}",
tcpstat->MaximumTransmissionTimeout );
Console::WriteLine( " Connection Data:" );
Console::WriteLine( " Current ............................ : {0}",
tcpstat->CurrentConnections );
Console::WriteLine( " Cumulative .......................... : {0}",
tcpstat->CumulativeConnections );
Console::WriteLine( " Initiated ........................... : {0}",
tcpstat->ConnectionsInitiated );
Console::WriteLine( " Accepted ............................ : {0}",
tcpstat->ConnectionsAccepted );
Console::WriteLine( " Failed Attempts ..................... : {0}",
tcpstat->FailedConnectionAttempts );
Console::WriteLine( " Reset ............................... : {0}",
tcpstat->ResetConnections );
Console::WriteLine( "" );
Console::WriteLine( " Segment Data:" );
Console::WriteLine( " Received ........................... : {0}",
tcpstat->SegmentsReceived );
Console::WriteLine( " Sent ................................ : {0}",
tcpstat->SegmentsSent );
Console::WriteLine( " Retransmitted ....................... : {0}",
tcpstat->SegmentsResent );
Console::WriteLine( "" );
}
public static void ShowTcpStatistics(NetworkInterfaceComponent version)
{
IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
TcpStatistics tcpstat = null;
Console.WriteLine("");
switch (version)
{
case NetworkInterfaceComponent.IPv4:
tcpstat = properties.GetTcpIPv4Statistics();
Console.WriteLine("TCP/IPv4 Statistics:");
break;
case NetworkInterfaceComponent.IPv6:
tcpstat = properties.GetTcpIPv6Statistics();
Console.WriteLine("TCP/IPv6 Statistics:");
break;
default:
throw new ArgumentException("version");
// break;
}
Console.WriteLine(" Minimum Transmission Timeout............. : {0}",
tcpstat.MinimumTransmissionTimeout);
Console.WriteLine(" Maximum Transmission Timeout............. : {0}",
tcpstat.MaximumTransmissionTimeout);
Console.WriteLine(" Connection Data:");
Console.WriteLine(" Current ............................ : {0}",
tcpstat.CurrentConnections);
Console.WriteLine(" Cumulative .......................... : {0}",
tcpstat.CumulativeConnections);
Console.WriteLine(" Initiated ........................... : {0}",
tcpstat.ConnectionsInitiated);
Console.WriteLine(" Accepted ............................ : {0}",
tcpstat.ConnectionsAccepted);
Console.WriteLine(" Failed Attempts ..................... : {0}",
tcpstat.FailedConnectionAttempts);
Console.WriteLine(" Reset ............................... : {0}",
tcpstat.ResetConnections);
Console.WriteLine("");
Console.WriteLine(" Segment Data:");
Console.WriteLine(" Received ........................... : {0}",
tcpstat.SegmentsReceived);
Console.WriteLine(" Sent ................................ : {0}",
tcpstat.SegmentsSent);
Console.WriteLine(" Retransmitted ....................... : {0}",
tcpstat.SegmentsResent);
Console.WriteLine("");
}
備註
TCP 是傳輸層通訊協議,負責可靠地傳送和接收數據封包。 它定義於 IETF RFC 793 中。
如需應用程式可用 TCP 流量統計資料的詳細資訊,請參閱 TcpStatistics 類別檔。 請注意,這個方法所傳回的物件會反映建立物件時所傳回的 TcpStatistics 統計數據。 此資訊不會動態更新。