Esempio n. 1
0
        protected override bool ReleaseHandle()
        {
            // NOTE: The SafeHandle class guarantees this will be called exactly once.
            var ptr = handle;

            handle = IntPtr.Zero;
            if (IntPtr.Zero != ptr)
            {
                SniNativeMethodWrapper.SNIPacketRelease(ptr);
            }
            return(true);
        }
Esempio n. 2
0
        public int Receive(byte[] readBuffer, int offset, int count)
        {
            var readPacketPtr = IntPtr.Zero;
            var error         = SniNativeMethodWrapper.SNIReadSyncOverAsync(_sniNativeHandle, ref readPacketPtr, 15000);

            if (error != TdsEnums.SNI_SUCCESS)
            {
                SniNativeMethodWrapper.SNIGetLastError(out var errorStruct);
                throw new Exception(errorStruct.errorMessage);
            }

            var dataSize = (uint)count;

            SniNativeMethodWrapper.SNIPacketGetData(readPacketPtr, readBuffer, ref dataSize);
            GetBytesString("Read- ", readBuffer, (int)dataSize);
            SniNativeMethodWrapper.SNIPacketRelease(readPacketPtr);
            return((int)dataSize);
        }