Export (0) Print
Expand All

UdpStatistics Class

Provides User Datagram Protocol (UDP) statistical data.

Namespace:  System.Net.NetworkInformation
Assembly:  System (in System.dll)

public abstract class UdpStatistics

Instances of this class are returned by the GetUdpIPv4Statistics and GetUdpIPv6Statistics methods to give applications access to UDP traffic information.

The information in this class correlates to the management information objects described in http://www.ietf.org/rfc/rfc2013.txt.

The following code example displays the UDP statistics for the specified address family.

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("");
}
void ShowUdpStatistics(NetworkInterfaceComponent version)
{
    IPGlobalProperties* properties = IPGlobalProperties::GetIPGlobalProperties();
    UdpStatistics* udpStat = 0;

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

System.Object
  System.Net.NetworkInformation.UdpStatistics

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft