System.Net.WebSockets.WebSocketBuffer.ConvertPinnedSendPayloadToNative C# (CSharp) Method

ConvertPinnedSendPayloadToNative() private method

private ConvertPinnedSendPayloadToNative ( byte buffer, int offset, int count ) : IntPtr
buffer byte
offset int
count int
return IntPtr
        internal IntPtr ConvertPinnedSendPayloadToNative(byte[] buffer, int offset, int count)
        {
            if (!IsPinnedSendPayloadBuffer(buffer, offset, count))
            {
                // Indicates a violation in the API contract that could indicate 
                // memory corruption because the pinned sendbuffer is shared between managed and native code
                throw new AccessViolationException();
            }

            Debug.Assert(Marshal.UnsafeAddrOfPinnedArrayElement(_pinnedSendBuffer.Array,
                _pinnedSendBuffer.Offset).ToInt64() == _pinnedSendBufferStartAddress,
                "'m_PinnedSendBuffer.Array' MUST be pinned during the entire send operation.");

            return new IntPtr(_pinnedSendBufferStartAddress + offset - _pinnedSendBuffer.Offset);
        }

Same methods

WebSocketBuffer::ConvertPinnedSendPayloadToNative ( ArraySegment payload ) : IntPtr