public static unsafe void GetAddrInfoAsync(DnsResolveAsyncResult asyncResult) { GetAddrInfoExContext *context = GetAddrInfoExContext.AllocateContext(); try { var state = new GetAddrInfoExState(asyncResult); context->QueryStateHandle = state.CreateHandle(); } catch { GetAddrInfoExContext.FreeContext(context); throw; } AddressInfoEx hints = new AddressInfoEx(); hints.ai_flags = AddressInfoHints.AI_CANONNAME; hints.ai_family = AddressFamily.Unspecified; // Gets all address families SocketError errorCode = (SocketError)Interop.Winsock.GetAddrInfoExW(asyncResult.HostName, null, 0 /* NS_ALL*/, IntPtr.Zero, ref hints, out context->Result, IntPtr.Zero, ref context->Overlapped, s_getAddrInfoExCallback, out context->CancelHandle); if (errorCode != SocketError.IOPending) { ProcessResult(errorCode, context); } }
internal static extern unsafe int GetAddrInfoExW( [In] string pName, [In] string pServiceName, [In] int dwNamespace, [In] IntPtr lpNspId, [In] ref AddressInfoEx pHints, [Out] out AddressInfoEx *ppResult, [In] IntPtr timeout, [In] ref NativeOverlapped lpOverlapped, [In] LPLOOKUPSERVICE_COMPLETION_ROUTINE lpCompletionRoutine, [Out] out IntPtr lpNameHandle );