예제 #1
0
        SslStatus NativeWriteCallback(IntPtr data, ref nint dataLength)
        {
            if (closed || disposed || parent == null)
            {
                return(SslStatus.ClosedAbort);
            }

            var len = (int)System.Math.Min(dataLength, writeBuffer.Length);

            Marshal.Copy(data, writeBuffer, 0, len);

            bool wantMore;
            var  ret = parent.InternalWrite(writeBuffer, 0, len, out wantMore);

            dataLength = len;

            if (ret < 0)
            {
                return(SslStatus.ClosedAbort);
            }
            else if (ret == 0)
            {
                return(SslStatus.ClosedGraceful);
            }

            return(wantMore ? SslStatus.WouldBlock : SslStatus.Success);
        }
예제 #2
0
        SslStatus NativeWriteCallback(IntPtr data, ref nint dataLength)
        {
            if (closed || disposed || parent == null)
            {
                return(SslStatus.ClosedAbort);
            }

            var len         = (int)dataLength;
            var writeBuffer = new byte [len];

            Marshal.Copy(data, writeBuffer, 0, len);

            Debug("NativeWriteCallback: {0}", len);

            var ok = parent.InternalWrite(writeBuffer, 0, len);

            Debug("NativeWriteCallback done: {0} {1}", len, ok);

            return(ok ? SslStatus.Success : SslStatus.ClosedAbort);
        }