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

◆ ParseAddressInfo()

static unsafe IPAddress[] System.Net.NameResolutionPal.ParseAddressInfo ( global::Interop::Winsock::AddressInfo * addressInfoPtr,
bool justAddresses,
out string hostName )
inlinestaticprivate

Definition at line 342 of file NameResolutionPal.cs.

343 {
344 int num = 0;
345 for (global::Interop.Winsock.AddressInfo* ptr = addressInfoPtr; ptr != null; ptr = ptr->ai_next)
346 {
347 int num2 = (int)ptr->ai_addrlen;
348 if (ptr->ai_family == AddressFamily.InterNetwork)
349 {
350 if (num2 == 16)
351 {
352 num++;
353 }
354 }
355 else if (SocketProtocolSupportPal.OSSupportsIPv6 && ptr->ai_family == AddressFamily.InterNetworkV6 && num2 == 28)
356 {
357 num++;
358 }
359 }
360 IPAddress[] array = new IPAddress[num];
361 num = 0;
362 string text = (justAddresses ? "NONNULLSENTINEL" : null);
363 for (global::Interop.Winsock.AddressInfo* ptr2 = addressInfoPtr; ptr2 != null; ptr2 = ptr2->ai_next)
364 {
365 if (text == null && ptr2->ai_canonname != null)
366 {
367 text = Marshal.PtrToStringUni((IntPtr)ptr2->ai_canonname);
368 }
369 int num3 = (int)ptr2->ai_addrlen;
370 ReadOnlySpan<byte> socketAddress = new ReadOnlySpan<byte>(ptr2->ai_addr, num3);
371 if (ptr2->ai_family == AddressFamily.InterNetwork)
372 {
373 if (num3 == 16)
374 {
375 array[num++] = CreateIPv4Address(socketAddress);
376 }
377 }
378 else if (SocketProtocolSupportPal.OSSupportsIPv6 && ptr2->ai_family == AddressFamily.InterNetworkV6 && num3 == 28)
379 {
380 array[num++] = CreateIPv6Address(socketAddress);
381 }
382 }
383 hostName = (justAddresses ? null : text);
384 return array;
385 }
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(), and System.text.

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