SystemUdpStatistics.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Net / System / Net / NetworkInformation / SystemUdpStatistics.cs / 1 / SystemUdpStatistics.cs

                             

    /// 
    ///    Provides support for ip configuation information and statistics.
    /// 
    ///
namespace System.Net.NetworkInformation { 
    using System.Net.Sockets; 
    using System;
    using System.ComponentModel; 



 
    /// Udp statistics.
    internal class SystemUdpStatistics:UdpStatistics { 
        MibUdpStats stats; 

        private SystemUdpStatistics(){} 
        internal SystemUdpStatistics(AddressFamily family){
            uint result;

            if (!ComNetOS.IsPostWin2K){ 
                if (family!= AddressFamily.InterNetwork){
                    throw new PlatformNotSupportedException(SR.GetString(SR.WinXPRequired)); 
                } 
                result = UnsafeNetInfoNativeMethods.GetUdpStatistics(out stats);
            } 
            else
                result = UnsafeNetInfoNativeMethods.GetUdpStatisticsEx(out stats, family);

            if (result != IpHelperErrors.Success) { 
                throw new NetworkInformationException((int)result);
            } 
        } 

        public override long DatagramsReceived{get {return stats.datagramsReceived;}} 
        public override long IncomingDatagramsDiscarded{get {return stats.incomingDatagramsDiscarded;}}
        public override long IncomingDatagramsWithErrors{get {return stats.incomingDatagramsWithErrors;}}
        public override long DatagramsSent{get {return stats.datagramsSent;}}
        public override int UdpListeners{get {return (int)stats.udpListeners;}} 
    }
 
 } 

 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
 

    /// 
    ///    Provides support for ip configuation information and statistics.
    /// 
    ///
namespace System.Net.NetworkInformation { 
    using System.Net.Sockets; 
    using System;
    using System.ComponentModel; 



 
    /// Udp statistics.
    internal class SystemUdpStatistics:UdpStatistics { 
        MibUdpStats stats; 

        private SystemUdpStatistics(){} 
        internal SystemUdpStatistics(AddressFamily family){
            uint result;

            if (!ComNetOS.IsPostWin2K){ 
                if (family!= AddressFamily.InterNetwork){
                    throw new PlatformNotSupportedException(SR.GetString(SR.WinXPRequired)); 
                } 
                result = UnsafeNetInfoNativeMethods.GetUdpStatistics(out stats);
            } 
            else
                result = UnsafeNetInfoNativeMethods.GetUdpStatisticsEx(out stats, family);

            if (result != IpHelperErrors.Success) { 
                throw new NetworkInformationException((int)result);
            } 
        } 

        public override long DatagramsReceived{get {return stats.datagramsReceived;}} 
        public override long IncomingDatagramsDiscarded{get {return stats.incomingDatagramsDiscarded;}}
        public override long IncomingDatagramsWithErrors{get {return stats.incomingDatagramsWithErrors;}}
        public override long DatagramsSent{get {return stats.datagramsSent;}}
        public override int UdpListeners{get {return (int)stats.udpListeners;}} 
    }
 
 } 

 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK