Пример #1
0
            /// <exception cref="System.IO.IOException"/>
            public override int Read(byte[] b, int off, int len)
            {
                this._enclosing.refCount.Reference();
                bool exc = true;

                try
                {
                    int nRead = DomainSocket.ReadArray0(this._enclosing.fd, b, off, len);
                    exc = false;
                    return(nRead);
                }
                finally
                {
                    this._enclosing.Unreference(exc);
                }
            }
Пример #2
0
            /// <exception cref="System.IO.IOException"/>
            public override int Read()
            {
                this._enclosing.refCount.Reference();
                bool exc = true;

                try
                {
                    byte[] b   = new byte[1];
                    int    ret = DomainSocket.ReadArray0(this._enclosing.fd, b, 0, 1);
                    exc = false;
                    return((ret >= 0) ? b[0] : -1);
                }
                finally
                {
                    this._enclosing.Unreference(exc);
                }
            }
Пример #3
0
            /// <exception cref="System.IO.IOException"/>
            public virtual int Read(ByteBuffer dst)
            {
                this._enclosing.refCount.Reference();
                bool exc = true;

                try
                {
                    int nread = 0;
                    if (dst.IsDirect())
                    {
                        nread = DomainSocket.ReadByteBufferDirect0(this._enclosing.fd, dst, dst.Position(
                                                                       ), dst.Remaining());
                    }
                    else
                    {
                        if (dst.HasArray())
                        {
                            nread = DomainSocket.ReadArray0(this._enclosing.fd, ((byte[])dst.Array()), dst.Position
                                                                () + dst.ArrayOffset(), dst.Remaining());
                        }
                        else
                        {
                            throw new Exception("we don't support " + "using ByteBuffers that aren't either direct or backed by "
                                                + "arrays");
                        }
                    }
                    if (nread > 0)
                    {
                        dst.Position(dst.Position() + nread);
                    }
                    exc = false;
                    return(nread);
                }
                finally
                {
                    this._enclosing.Unreference(exc);
                }
            }