Exemple #1
0
 private void EnsureWSARecvMsg(SafeCloseSocket socketHandle)
 {
     if (this.recvMsg == null)
     {
         lock (this.lockObject)
         {
             if (this.recvMsg == null)
             {
                 Guid   guid = new Guid("{0xf689d7c8,0x6f1f,0x436b,{0x8a,0x53,0xe5,0x4f,0xe3,0x51,0xc3,0x22}}");
                 IntPtr ptr  = this.LoadDynamicFunctionPointer(socketHandle, ref guid);
                 this.recvMsg          = (WSARecvMsgDelegate)Marshal.GetDelegateForFunctionPointer(ptr, typeof(WSARecvMsgDelegate));
                 this.recvMsg_Blocking = (WSARecvMsgDelegate_Blocking)Marshal.GetDelegateForFunctionPointer(ptr, typeof(WSARecvMsgDelegate_Blocking));
             }
         }
     }
 }
Exemple #2
0
        private void LoadWSARecvMsg()
        {
            SocketError errorCode;
            IntPtr ptrWSARecvMsg = IntPtr.Zero;

            unsafe
            {
                int length;
                Guid guid = new Guid("{0xf689d7c8,0x6f1f,0x436b,{0x8a,0x53,0xe5,0x4f,0xe3,0x51,0xc3,0x22}}");

                // This can throw ObjectDisposedException.
                errorCode = UnsafeNclNativeMethods.OSSOCK.WSAIoctl(
                    m_Handle,
                    IoctlSocketConstants.SIOGETEXTENSIONFUNCTIONPOINTER,
                    ref guid,
                    sizeof(Guid),
                    out ptrWSARecvMsg,
                    sizeof(IntPtr),
                    out length,
                    IntPtr.Zero,
                    IntPtr.Zero);
            }

            if (errorCode != SocketError.Success)
            {
                throw new SocketException();
            }
            s_WSARecvMsg = (WSARecvMsgDelegate) Marshal.GetDelegateForFunctionPointer(ptrWSARecvMsg, typeof(WSARecvMsgDelegate));
            s_WSARecvMsg_Blocking = (WSARecvMsgDelegate_Blocking) Marshal.GetDelegateForFunctionPointer(ptrWSARecvMsg, typeof(WSARecvMsgDelegate_Blocking));
        }