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

◆ TryGetNameInfo()

static unsafe string System.Net.NameResolutionPal.TryGetNameInfo ( IPAddress addr,
out SocketError errorCode,
out int nativeErrorCode )
inlinestatic

Definition at line 228 of file NameResolutionPal.cs.

229 {
230 global::Interop.Winsock.EnsureInitialized();
231 SocketAddress socketAddress = new IPEndPoint(addr, 0).Serialize();
232 Span<byte> span = ((socketAddress.Size > 64) ? ((Span<byte>)new byte[socketAddress.Size]) : stackalloc byte[64]);
233 Span<byte> span2 = span;
234 for (int i = 0; i < socketAddress.Size; i++)
235 {
236 span2[i] = socketAddress[i];
237 }
238 char* ptr = stackalloc char[1025];
239 fixed (byte* pSockaddr = span2)
240 {
241 errorCode = global::Interop.Winsock.GetNameInfoW(pSockaddr, socketAddress.Size, ptr, 1025, null, 0, 4);
242 }
243 if (errorCode == SocketError.Success)
244 {
245 nativeErrorCode = 0;
246 return new string(ptr);
247 }
248 nativeErrorCode = (int)errorCode;
249 return null;
250 }

References System.Net.IPEndPoint.Serialize(), and System.Net.SocketAddress.Size.

Referenced by System.Net.Dns.GetHostEntryOrAddressesCore().