Ejemplo n.º 1
0
        public override int Read(byte[] buf, int off, int len)
        {
            CheckNotDisposed();
            ValidateBufferArgs(buf, off, len);
            if (!IsOpen)
            {
                throw new TTransportException(TTransportException.ExceptionType.NotOpen);
            }

            if (inputBuffer.Capacity < bufSize)
            {
                inputBuffer.Capacity = bufSize;
            }

            while (true)
            {
                int got = inputBuffer.Read(buf, off, len);
                if (got > 0)
                {
                    return(got);
                }

                inputBuffer.Seek(0, SeekOrigin.Begin);
                inputBuffer.SetLength(inputBuffer.Capacity);
                int filled = transport.Read(inputBuffer.GetBuffer(), 0, (int)inputBuffer.Length);
                inputBuffer.SetLength(filled);
                if (filled == 0)
                {
                    return(0);
                }
            }
        }