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

◆ GetActiveUdpListeners()

unsafe override IPEndPoint[] System.Net.NetworkInformation.SystemIPGlobalProperties.GetActiveUdpListeners ( )
inline

Definition at line 149 of file SystemIPGlobalProperties.cs.

150 {
151 uint dwOutBufLen = 0u;
152 uint num = 0u;
155 {
156 num = global::Interop.IpHlpApi.GetUdpTable(IntPtr.Zero, ref dwOutBufLen, order: true);
157 while (true)
158 {
159 switch (num)
160 {
161 case 122u:
162 {
164 try
165 {
166 num = global::Interop.IpHlpApi.GetUdpTable(intPtr, ref dwOutBufLen, order: true);
167 if (num != 0)
168 {
169 continue;
170 }
172 ref readonly global::Interop.IpHlpApi.MibUdpTable reference = ref MemoryMarshal.AsRef<global::Interop.IpHlpApi.MibUdpTable>(span);
173 if (reference.numberOfEntries != 0)
174 {
175 span = span.Slice(sizeof(global::Interop.IpHlpApi.MibUdpTable));
176 for (int i = 0; i < reference.numberOfEntries; i++)
177 {
178 ref readonly global::Interop.IpHlpApi.MibUdpRow reference2 = ref MemoryMarshal.AsRef<global::Interop.IpHlpApi.MibUdpRow>(span);
179 int port = (reference2.localPort1 << 8) | reference2.localPort2;
180 list.Add(new IPEndPoint(reference2.localAddr, port));
181 span = span.Slice(sizeof(global::Interop.IpHlpApi.MibUdpRow));
182 }
183 }
184 }
185 finally
186 {
188 }
189 continue;
190 }
191 default:
192 throw new NetworkInformationException((int)num);
193 case 0u:
194 case 232u:
195 break;
196 }
197 break;
198 }
199 }
201 {
202 dwOutBufLen = 0u;
203 num = global::Interop.IpHlpApi.GetExtendedUdpTable(IntPtr.Zero, ref dwOutBufLen, order: true, 23u, global::Interop.IpHlpApi.UdpTableClass.UdpTableOwnerPid, 0u);
204 while (true)
205 {
206 switch (num)
207 {
208 case 122u:
209 {
211 try
212 {
213 num = global::Interop.IpHlpApi.GetExtendedUdpTable(intPtr2, ref dwOutBufLen, order: true, 23u, global::Interop.IpHlpApi.UdpTableClass.UdpTableOwnerPid, 0u);
214 if (num != 0)
215 {
216 continue;
217 }
219 ref readonly global::Interop.IpHlpApi.MibUdp6TableOwnerPid reference3 = ref MemoryMarshal.AsRef<global::Interop.IpHlpApi.MibUdp6TableOwnerPid>(span2);
220 if (reference3.numberOfEntries != 0)
221 {
222 span2 = span2.Slice(sizeof(global::Interop.IpHlpApi.MibUdp6TableOwnerPid));
223 for (int j = 0; j < reference3.numberOfEntries; j++)
224 {
225 ref readonly global::Interop.IpHlpApi.MibUdp6RowOwnerPid reference4 = ref MemoryMarshal.AsRef<global::Interop.IpHlpApi.MibUdp6RowOwnerPid>(span2);
226 int port2 = (reference4.localPort1 << 8) | reference4.localPort2;
227 list.Add(new IPEndPoint(new IPAddress(reference4.localAddrAsSpan, reference4.localScopeId), port2));
228 span2 = span2.Slice(sizeof(global::Interop.IpHlpApi.MibUdp6RowOwnerPid));
229 }
230 }
231 }
232 finally
233 {
235 }
236 continue;
237 }
238 default:
239 throw new NetworkInformationException((int)num);
240 case 0u:
241 case 232u:
242 break;
243 }
244 break;
245 }
246 }
247 return list.ToArray();
248 }
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.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.