Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetAllTcpConnections()

unsafe List< SystemTcpConnectionInformation > System.Net.NetworkInformation.SystemIPGlobalProperties.GetAllTcpConnections ( )
inlineprivate

Definition at line 52 of file SystemIPGlobalProperties.cs.

53 {
54 uint dwOutBufLen = 0u;
55 uint num = 0u;
58 {
59 num = global::Interop.IpHlpApi.GetTcpTable(IntPtr.Zero, ref dwOutBufLen, order: true);
60 while (true)
61 {
62 switch (num)
63 {
64 case 122u:
65 {
67 try
68 {
69 num = global::Interop.IpHlpApi.GetTcpTable(intPtr, ref dwOutBufLen, order: true);
70 if (num != 0)
71 {
72 continue;
73 }
75 ref readonly global::Interop.IpHlpApi.MibTcpTable reference = ref MemoryMarshal.AsRef<global::Interop.IpHlpApi.MibTcpTable>(span);
76 if (reference.numberOfEntries != 0)
77 {
78 span = span.Slice(sizeof(global::Interop.IpHlpApi.MibTcpTable));
79 for (int i = 0; i < reference.numberOfEntries; i++)
80 {
81 list.Add(new SystemTcpConnectionInformation(in MemoryMarshal.AsRef<global::Interop.IpHlpApi.MibTcpRow>(span)));
82 span = span.Slice(sizeof(global::Interop.IpHlpApi.MibTcpRow));
83 }
84 }
85 }
86 finally
87 {
89 }
90 continue;
91 }
92 default:
93 throw new NetworkInformationException((int)num);
94 case 0u:
95 case 232u:
96 break;
97 }
98 break;
99 }
100 }
102 {
103 dwOutBufLen = 0u;
104 num = global::Interop.IpHlpApi.GetExtendedTcpTable(IntPtr.Zero, ref dwOutBufLen, order: true, 23u, global::Interop.IpHlpApi.TcpTableClass.TcpTableOwnerPidAll, 0u);
105 while (true)
106 {
107 switch (num)
108 {
109 case 122u:
110 {
112 try
113 {
114 num = global::Interop.IpHlpApi.GetExtendedTcpTable(intPtr2, ref dwOutBufLen, order: true, 23u, global::Interop.IpHlpApi.TcpTableClass.TcpTableOwnerPidAll, 0u);
115 if (num != 0)
116 {
117 continue;
118 }
120 ref readonly global::Interop.IpHlpApi.MibTcp6TableOwnerPid reference2 = ref MemoryMarshal.AsRef<global::Interop.IpHlpApi.MibTcp6TableOwnerPid>(span2);
121 if (reference2.numberOfEntries != 0)
122 {
123 span2 = span2.Slice(sizeof(global::Interop.IpHlpApi.MibTcp6TableOwnerPid));
124 for (int j = 0; j < reference2.numberOfEntries; j++)
125 {
126 list.Add(new SystemTcpConnectionInformation(in MemoryMarshal.AsRef<global::Interop.IpHlpApi.MibTcp6RowOwnerPid>(span2)));
127 span2 = span2.Slice(sizeof(global::Interop.IpHlpApi.MibTcp6RowOwnerPid));
128 }
129 }
130 }
131 finally
132 {
134 }
135 continue;
136 }
137 default:
138 throw new NetworkInformationException((int)num);
139 case 0u:
140 case 232u:
141 break;
142 }
143 break;
144 }
145 }
146 return list;
147 }
void Add(TKey key, TValue value)
static bool OSSupportsIPv6
Definition Socket.cs:591
static bool OSSupportsIPv4
Definition Socket.cs:589
static void FreeHGlobal(IntPtr hglobal)
Definition Marshal.cs:1680
static IntPtr AllocHGlobal(int cb)
Definition Marshal.cs:625

References System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Runtime.InteropServices.Marshal.AllocHGlobal(), System.Runtime.InteropServices.Marshal.FreeHGlobal(), System.list, System.Net.Sockets.Socket.OSSupportsIPv4, System.Net.Sockets.Socket.OSSupportsIPv6, and System.IntPtr.Zero.

Referenced by System.Net.NetworkInformation.SystemIPGlobalProperties.GetActiveTcpConnections(), and System.Net.NetworkInformation.SystemIPGlobalProperties.GetActiveTcpListeners().