語言

UdpStatistics 類別

定義

提供使用者資料報協定(UDP)統計資料。

public ref class UdpStatistics abstract
public abstract class UdpStatistics
type UdpStatistics = class
Public MustInherit Class UdpStatistics
繼承
UdpStatistics

範例

以下程式碼範例顯示指定地址族群的 UDP 統計數據。

public static void ShowUdpStatistics(NetworkInterfaceComponent version)
{
    IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
    UdpStatistics udpStat = null;

    switch (version)
    {
        case NetworkInterfaceComponent.IPv4:
            udpStat = properties.GetUdpIPv4Statistics();
            Console.WriteLine("UDP IPv4 Statistics");
            break;
        case NetworkInterfaceComponent.IPv6:
            udpStat = properties.GetUdpIPv6Statistics();
            Console.WriteLine("UDP IPv6 Statistics");
            break;
        default:
            throw new ArgumentException("version");
        //    break;
    }
    Console.WriteLine("  Datagrams Received ...................... : {0}",
        udpStat.DatagramsReceived);
    Console.WriteLine("  Datagrams Sent .......................... : {0}",
        udpStat.DatagramsSent);
    Console.WriteLine("  Incoming Datagrams Discarded ............ : {0}",
        udpStat.IncomingDatagramsDiscarded);
    Console.WriteLine("  Incoming Datagrams With Errors .......... : {0}",
        udpStat.IncomingDatagramsWithErrors);
    Console.WriteLine("  UDP Listeners ........................... : {0}",
        udpStat.UdpListeners);
    Console.WriteLine("");
}

備註

此類別的實例由 和 GetUdpIPv4Statistics 方法回傳GetUdpIPv6Statistics,以讓應用程式存取 UDP 流量資訊。

此類別中的資訊對應於 中 https://www.ietf.org/rfc/rfc2013.txt描述的管理資訊物件。

建構函式

名稱 Description
UdpStatistics()

初始化 UdpStatistics 類別的新執行個體。

屬性

名稱 Description
DatagramsReceived

取得收到的使用者資料報協定(UDP)資料報數量。

DatagramsSent

取得已傳送的使用者資料報協定(UDP)資料報數量。

IncomingDatagramsDiscarded

取得因埠錯誤而接收及丟棄的使用者資料報協定(UDP)資料報數量。

IncomingDatagramsWithErrors

取得因錯誤(非埠資訊錯誤)而被接收及丟棄的使用者資料報協定(UDP)資料報數量。

UdpListeners

取得正在監聽使用者資料報協定(UDP)資料報的本地端點數量。

方法

名稱 Description
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設哈希函式。

(繼承來源 Object)
GetType()

取得目前實例的 Type。

(繼承來源 Object)
MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
ToString()

傳回表示目前 物件的字串。

(繼承來源 Object)

適用於