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

◆ ParseAddressInfoEx()

static unsafe IPAddress[] System.Net.NameResolutionPal.ParseAddressInfoEx ( global::Interop::Winsock::AddressInfoEx * addressInfoExPtr,
bool justAddresses,
out string hostName )
inlinestaticprivate

Definition at line 387 of file NameResolutionPal.cs.

388 {
389 int num = 0;
390 for (global::Interop.Winsock.AddressInfoEx* ptr = addressInfoExPtr; ptr != null; ptr = ptr->ai_next)
391 {
392 int num2 = (int)ptr->ai_addrlen;
393 if (ptr->ai_family == AddressFamily.InterNetwork)
394 {
395 if (num2 == 16)
396 {
397 num++;
398 }
399 }
400 else if (SocketProtocolSupportPal.OSSupportsIPv6 && ptr->ai_family == AddressFamily.InterNetworkV6 && num2 == 28)
401 {
402 num++;
403 }
404 }
405 IPAddress[] array = new IPAddress[num];
406 num = 0;
407 string text = (justAddresses ? "NONNULLSENTINEL" : null);
408 for (global::Interop.Winsock.AddressInfoEx* ptr2 = addressInfoExPtr; ptr2 != null; ptr2 = ptr2->ai_next)
409 {
410 if (text == null && ptr2->ai_canonname != IntPtr.Zero)
411 {
412 text = Marshal.PtrToStringUni(ptr2->ai_canonname);
413 }
414 int num3 = (int)ptr2->ai_addrlen;
415 ReadOnlySpan<byte> socketAddress = new ReadOnlySpan<byte>(ptr2->ai_addr, num3);
416 if (ptr2->ai_family == AddressFamily.InterNetwork)
417 {
418 if (num3 == 16)
419 {
420 array[num++] = CreateIPv4Address(socketAddress);
421 }
422 }
423 else if (SocketProtocolSupportPal.OSSupportsIPv6 && ptr2->ai_family == AddressFamily.InterNetworkV6 && num3 == 28)
424 {
425 array[num++] = CreateIPv6Address(socketAddress);
426 }
427 }
428 hostName = (justAddresses ? null : text);
429 return array;
430 }
static IPAddress CreateIPv6Address(ReadOnlySpan< byte > socketAddress)
static IPAddress CreateIPv4Address(ReadOnlySpan< byte > socketAddress)
static unsafe? string PtrToStringUni(IntPtr ptr)
Definition Marshal.cs:652

References System.array, System.Net.NameResolutionPal.CreateIPv4Address(), System.Net.NameResolutionPal.CreateIPv6Address(), System.Net.SocketProtocolSupportPal.OSSupportsIPv6, System.Runtime.InteropServices.Marshal.PtrToStringUni(), System.text, and System.IntPtr.Zero.

Referenced by System.Net.NameResolutionPal.ProcessResult().