System.Net.NetworkInformation.Win32IPGlobalProperties.FillTcpTable C# (CSharp) Method

FillTcpTable() private method

private FillTcpTable ( List &tab4, List &tab6 ) : void
tab4 List
tab6 List
return void
		unsafe void FillTcpTable (out List<Win32_MIB_TCPROW> tab4, out List<Win32_MIB_TCP6ROW> tab6)
		{
			tab4 = new List<Win32_MIB_TCPROW> ();
			int size4 = 0;
			GetTcpTable (null, ref size4, true); // get size
			byte [] bytes4 = new byte [size4];
			GetTcpTable (bytes4, ref size4, true); // get list

			int structSize4 = Marshal.SizeOf (typeof (Win32_MIB_TCPROW));

			fixed (byte* ptr = bytes4) {
				int count = Marshal.ReadInt32 ((IntPtr) ptr);
				for (int i = 0; i < count; i++) {
					Win32_MIB_TCPROW row = new Win32_MIB_TCPROW ();
					Marshal.PtrToStructure ((IntPtr) (ptr + i * structSize4 + 4), row);
					tab4.Add (row);
				}
			}

			tab6 = new List<Win32_MIB_TCP6ROW> ();
			if (Environment.OSVersion.Version.Major >= 6) { // Vista
				int size6 = 0;
				GetTcp6Table (null, ref size6, true); // get size
				byte [] bytes6 = new byte [size6];
				GetTcp6Table (bytes6, ref size6, true); // get list

				int structSize6 = Marshal.SizeOf (typeof (Win32_MIB_TCP6ROW));

				fixed (byte* ptr = bytes6) {
					int count = Marshal.ReadInt32 ((IntPtr) ptr);
					for (int i = 0; i < count; i++) {
						Win32_MIB_TCP6ROW row = new Win32_MIB_TCP6ROW ();
						Marshal.PtrToStructure ((IntPtr) (ptr + i * structSize6 + 4), row);
						tab6.Add (row);
					}
				}
			}
		}