// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Runtime.InteropServices; namespace E { public class Program { [StructLayout(LayoutKind.Sequential)] public struct MIB_TCPSTATS { public int dwRtoAlgorithm ; public int dwRtoMin ; public int dwRtoMax ; public int dwMaxConn ; public int dwActiveOpens ; public int dwPassiveOpens ; public int dwAttemptFails ; public int dwEstabResets ; public int dwCurrEstab ; public int dwInSegs ; public int dwOutSegs ; public int dwRetransSegs ; public int dwInErrs ; public int dwOutRsts ; public int dwNumConns ; } [DllImport("iphlpapi.dll",SetLastError=true)] public extern static int GetTcpStatistics (out MIB_TCPSTATS pStats ); public static void Main(string[] args) { MIB_TCPSTATS tcpstats; GetTcpStatistics(out tcpstats); Console.WriteLine(tcpstats.dwRetransSegs); } } }