Beispiel #1
0
    public void finishRead(IceInternal.Buffer buf)
    {
        _configuration.checkReadException();
        if (_buffered)
        {
            if (buf.b.hasRemaining())
            {
                _transceiver.finishRead(_readBuffer);

                int pos       = _readBuffer.b.position();
                int requested = buf.b.remaining();
                int available = pos - _readBufferPos;
                if (available > 0)
                {
                    if (available >= requested)
                    {
                        available = requested;
                    }

                    byte[] arr = new byte[available];
                    _readBuffer.b.position(_readBufferPos);
                    _readBuffer.b.get(arr);
                    buf.b.put(arr);
                    _readBufferPos += available;
                    _readBuffer.b.position(pos);
                }
            }
        }
        else
        {
            _transceiver.finishRead(buf);
        }
    }
Beispiel #2
0
 public bool startRead(IceInternal.Buffer buf, IceInternal.AsyncCallback callback, object state)
 {
     if (_configuration.readReady())
     {
         _configuration.checkReadException(); // Only raise if we're configured to read now.
     }
     return(_transceiver.startRead(buf, callback, state));
 }
Beispiel #3
0
    public int write(IceInternal.Buffer buf)
    {
        if (!_configuration.writeReady() && buf.b.hasRemaining())
        {
            return(IceInternal.SocketOperation.Write);
        }

        _configuration.checkWriteException();
        return(_transceiver.write(buf));
    }
Beispiel #4
0
 //
 // Only for use by Connector, Acceptor
 //
 internal Transceiver(IceInternal.Transceiver transceiver)
 {
     _transceiver   = transceiver;
     _configuration = Configuration.getInstance();
     _initialized   = false;
     _readBuffer    = new IceInternal.Buffer();
     _readBuffer.resize(1024 * 8, true); // 8KB buffer
     _readBuffer.b.position(0);
     _readBufferPos = 0;
     _buffered      = _configuration.buffered();
 }
Beispiel #5
0
 //
 // Only for use by Connector, Acceptor
 //
 internal Transceiver(IceInternal.Transceiver transceiver)
 {
     _transceiver = transceiver;
     _configuration = Configuration.getInstance();
     _initialized = false;
     _readBuffer = new IceInternal.Buffer();
     _readBuffer.resize(1024 * 8, true); // 8KB buffer
     _readBuffer.b.position(0);
     _readBufferPos = 0;
     _buffered = _configuration.buffered();
 }
Beispiel #6
0
        public Buffer(Buffer buf, bool adopt)
        {
            b = buf.b;
            _size = buf._size;
            _capacity = buf._capacity;
            _shrinkCounter = buf._shrinkCounter;
            _order = buf._order;

            if(adopt)
            {
                buf.clear();
            }
        }
Beispiel #7
0
    public int read(IceInternal.Buffer buf, ref bool hasMoreData)
    {
        if (!_configuration.readReady() && buf.b.hasRemaining())
        {
            return(IceInternal.SocketOperation.Read);
        }

        _configuration.checkReadException();

        if (_buffered)
        {
            while (buf.b.hasRemaining())
            {
                if (_readBufferPos == _readBuffer.b.position())
                {
                    _readBufferPos = 0;
                    _readBuffer.b.position(0);
                    _transceiver.read(_readBuffer, ref hasMoreData);
                    if (_readBufferPos == _readBuffer.b.position())
                    {
                        hasMoreData = false;
                        return(IceInternal.SocketOperation.Read);
                    }
                }

                int pos = _readBuffer.b.position();
                Debug.Assert(pos > _readBufferPos);
                int requested = buf.b.remaining();
                int available = pos - _readBufferPos;
                Debug.Assert(available > 0);
                if (available >= requested)
                {
                    available = requested;
                }

                byte[] arr = new byte[available];
                _readBuffer.b.position(_readBufferPos);
                _readBuffer.b.get(arr);
                buf.b.put(arr);
                _readBufferPos += available;
                _readBuffer.b.position(pos);
            }
            hasMoreData = _readBufferPos < _readBuffer.b.position();
            return(IceInternal.SocketOperation.None);
        }
        else
        {
            return(_transceiver.read(buf, ref hasMoreData));
        }
    }
Beispiel #8
0
 public int initialize(IceInternal.Buffer readBuffer, IceInternal.Buffer writeBuffer, ref bool hasMoreData)
 {
     _configuration.checkInitializeException();
     if (!_initialized)
     {
         int status = _transceiver.initialize(readBuffer, writeBuffer, ref hasMoreData);
         if (status != IceInternal.SocketOperation.None)
         {
             return(status);
         }
         _initialized = true;
     }
     return(IceInternal.SocketOperation.None);
 }
Beispiel #9
0
    public bool read(IceInternal.Buffer buf)
    {
        if (!_initialized)
        {
            throw new Ice.SocketException();
        }

        if (!_configuration.readReady())
        {
            return(false);
        }

        _configuration.checkReadException();
        return(_transceiver.read(buf));
    }
Beispiel #10
0
    public bool startRead(IceInternal.Buffer buf, IceInternal.AsyncCallback callback, object state)
    {
        if (_configuration.readReady())
        {
            _configuration.checkReadException(); // Only raise if we're configured to read now.
        }
        if (_buffered)
        {
            int pos       = _readBuffer.b.position();
            int available = pos - _readBufferPos;
            if (available > 0)
            {
                int requested = buf.b.remaining();
                if (available >= requested)
                {
                    available = requested;
                }

                byte[] arr = new byte[available];
                _readBuffer.b.position(_readBufferPos);
                _readBuffer.b.get(arr);
                buf.b.put(arr);
                _readBufferPos += available;
                _readBuffer.b.position(pos);
            }

            if (_readBufferPos == _readBuffer.b.position() && buf.b.hasRemaining())
            {
                _readBufferPos = 0;
                _readBuffer.b.position(0);
                return(_transceiver.startRead(_readBuffer, callback, state));
            }
            else
            {
                Debug.Assert(!buf.b.hasRemaining());
                return(true); // Completed synchronously
            }
        }
        else
        {
            return(_transceiver.startRead(buf, callback, state));
        }
    }
Beispiel #11
0
 public int endWrite(Buffer buf)
 {
     // Once the request is sent, read the response
     return(buf.b.hasRemaining() ? SocketOperation.Write : SocketOperation.Read);
 }
Beispiel #12
0
 public void checkSendSize(Buffer buf)
 {
 }
Beispiel #13
0
 public void checkSendSize(IceInternal.Buffer buf)
 {
     _transceiver.checkSendSize(buf);
 }
Beispiel #14
0
 public int read(Buffer buf, ref bool hasMoreData)
 {
     return _stream.read(buf);
 }
Beispiel #15
0
 public void finishWrite(IceInternal.Buffer buf)
 {
     _configuration.checkWriteException();
     _transceiver.finishWrite(buf);
 }
Beispiel #16
0
 public void finishWrite(Buffer buf)
 {
     _stream.finishWrite(buf);
 }
Beispiel #17
0
 public bool startRead(Buffer buf, AsyncCallback callback, object state)
 {
     return _stream.startRead(buf, callback, state);
 }
Beispiel #18
0
 public bool startWrite(IceInternal.Buffer buf, IceInternal.AsyncCallback callback, object state, out bool completed)
 {
     _configuration.checkWriteException();
     return(_transceiver.startWrite(buf, callback, state, out completed));
 }
Beispiel #19
0
 public bool startWrite(Buffer buf, AsyncCallback callback, object state, out bool completed)
 {
     return _stream.startWrite(buf, callback, state, out completed);
 }
Beispiel #20
0
 public void finishRead(Buffer buf)
 {
     _stream.finishRead(buf);
 }
Beispiel #21
0
 public void finishRead(IceInternal.Buffer buf)
 {
     _configuration.checkReadException();
     _transceiver.finishRead(buf);
 }
Beispiel #22
0
 public int write(Buffer buf)
 {
     return _stream.write(buf);
 }
Beispiel #23
0
 public int endRead(Buffer buf)
 {
     // We're done once we read the response
     return(buf.b.hasRemaining() ? SocketOperation.Read : SocketOperation.None);
 }
Beispiel #24
0
 public void checkSendSize(IceInternal.Buffer buf, int messageSizeMax)
 {
     _transceiver.checkSendSize(buf, messageSizeMax);
 }
Beispiel #25
0
 public int initialize(Buffer readBuffer, Buffer writeBuffer, ref bool hasMoreData)
 {
     return _stream.connect(readBuffer, writeBuffer, ref hasMoreData);
 }