internal bool DisconnectEx(SafeCloseSocket socketHandle, SafeHandle overlapped, int flags, int reserved) { EnsureDynamicWinsockMethods(); DisconnectExDelegate disconnectEx = _dynamicWinsockMethods.GetDelegate <DisconnectExDelegate>(socketHandle); return(disconnectEx(socketHandle, overlapped, flags, reserved)); }
private void EnsureDisconnectEx(SafeCloseSocket socketHandle) { if (this.disconnectEx == null) { lock (this.lockObject) { if (this.disconnectEx == null) { Guid guid = new Guid("{0x7fda2e11,0x8630,0x436f,{0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}}"); IntPtr ptr = this.LoadDynamicFunctionPointer(socketHandle, ref guid); this.disconnectEx = (DisconnectExDelegate)Marshal.GetDelegateForFunctionPointer(ptr, typeof(DisconnectExDelegate)); this.disconnectEx_Blocking = (DisconnectExDelegate_Blocking)Marshal.GetDelegateForFunctionPointer(ptr, typeof(DisconnectExDelegate_Blocking)); } } } }
private void EnsureDisconnectEx(SafeCloseSocket socketHandle) { if (_disconnectEx == null) { lock (_lockObject) { if (_disconnectEx == null) { Guid guid = new Guid("{0x7fda2e11,0x8630,0x436f,{0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}}"); IntPtr ptrDisconnectEx = LoadDynamicFunctionPointer(socketHandle, ref guid); _disconnectEx = Marshal.GetDelegateForFunctionPointer <DisconnectExDelegate>(ptrDisconnectEx); _disconnectExBlocking = Marshal.GetDelegateForFunctionPointer <DisconnectExDelegateBlocking>(ptrDisconnectEx); } } } }
private void LoadDisconnectEx() { SocketError errorCode; IntPtr ptrDisconnectEx = IntPtr.Zero; unsafe { int length; Guid guid = new Guid("{0x7fda2e11,0x8630,0x436f,{0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}}"); // This can throw ObjectDisposedException. errorCode = UnsafeNclNativeMethods.OSSOCK.WSAIoctl( m_Handle, IoctlSocketConstants.SIOGETEXTENSIONFUNCTIONPOINTER, ref guid, sizeof(Guid), out ptrDisconnectEx, sizeof(IntPtr), out length, IntPtr.Zero, IntPtr.Zero); } if (errorCode != SocketError.Success) { throw new SocketException(); } s_DisconnectEx = (DisconnectExDelegate) Marshal.GetDelegateForFunctionPointer(ptrDisconnectEx, typeof(DisconnectExDelegate)); s_DisconnectEx_Blocking = (DisconnectExDelegate_Blocking)Marshal.GetDelegateForFunctionPointer(ptrDisconnectEx, typeof(DisconnectExDelegate_Blocking)); }