Class TransportImpl

    • Field Detail

      • data_already_read

        private java.nio.ByteBuffer data_already_read
      • read_waiter

        private volatile EventWaiter read_waiter
      • write_waiter

        private volatile EventWaiter write_waiter
      • is_ready_for_write

        private volatile boolean is_ready_for_write
      • is_ready_for_read

        private volatile boolean is_ready_for_read
      • write_select_failure

        private java.lang.Throwable write_select_failure
      • read_select_failure

        private java.lang.Throwable read_select_failure
      • last_ready_for_read

        private long last_ready_for_read
      • trace

        private boolean trace
    • Constructor Detail

      • TransportImpl

        protected TransportImpl()
    • Method Detail

      • setAlreadyRead

        public void setAlreadyRead​(java.nio.ByteBuffer bytes_already_read)
        Description copied from interface: Transport
        Inject the given already-read data back into the read stream.
        Specified by:
        setAlreadyRead in interface Transport
        Parameters:
        bytes_already_read - data
      • getEncryption

        public java.lang.String getEncryption​(boolean verbose)
        Description copied from interface: Transport
        Return a textual description of the encryption for this transport
        Specified by:
        getEncryption in interface Transport
        Returns:
      • getProtocol

        public java.lang.String getProtocol()
        Specified by:
        getProtocol in interface Transport
      • isSOCKS

        public boolean isSOCKS()
        Specified by:
        isSOCKS in interface Transport
      • isReadyForWrite

        public boolean isReadyForWrite​(EventWaiter waiter)
        Is the transport ready to write, i.e. will a write request result in >0 bytes written.
        Specified by:
        isReadyForWrite in interface TransportBase
        Returns:
        true if the transport is write ready, false if not yet ready
      • readyForWrite

        protected boolean readyForWrite​(boolean ready)
      • writeFailed

        protected void writeFailed​(java.lang.Throwable msg)
      • isReadyForRead

        public long isReadyForRead​(EventWaiter waiter)
        Is the transport ready to read, i.e. will a read request result in >0 bytes read.
        Specified by:
        isReadyForRead in interface TransportBase
        Returns:
        0 if the transport is read ready, millis since last ready or -1 if never ready
      • readyForRead

        protected boolean readyForRead​(boolean ready)
      • setReadyForRead

        public void setReadyForRead()
        Description copied from interface: Transport
        fake a wakeup so that a read cycle is attempted
        Specified by:
        setReadyForRead in interface Transport
      • readFailed

        protected void readFailed​(java.lang.Throwable msg)
      • write

        public long write​(java.nio.ByteBuffer[] buffers,
                          int array_offset,
                          int length)
                   throws java.io.IOException
        Write data to the transport from the given buffers. NOTE: Works like GatheringByteChannel.
        Specified by:
        write in interface Transport
        Parameters:
        buffers - from which bytes are to be retrieved
        array_offset - offset within the buffer array of the first buffer from which bytes are to be retrieved
        length - maximum number of buffers to be accessed
        Returns:
        number of bytes written
        Throws:
        java.io.IOException - on write error
      • read

        public long read​(java.nio.ByteBuffer[] buffers,
                         int array_offset,
                         int length)
                  throws java.io.IOException
        Read data from the transport into the given buffers. NOTE: Works like ScatteringByteChannel.
        Specified by:
        read in interface Transport
        Parameters:
        buffers - into which bytes are to be placed
        array_offset - offset within the buffer array of the first buffer into which bytes are to be placed
        length - maximum number of buffers to be accessed
        Returns:
        number of bytes read
        Throws:
        java.io.IOException - on read error
      • requestWriteSelect

        private void requestWriteSelect()
      • requestReadSelect

        private void requestReadSelect()
      • connectedInbound

        public void connectedInbound()
        Description copied from interface: Transport
        Indicate that inbound connection is complete
        Specified by:
        connectedInbound in interface Transport
      • connectedOutbound

        public void connectedOutbound()
      • getUserData

        public java.lang.Object getUserData​(java.lang.Object key)
        Specified by:
        getUserData in interface Transport
      • setUserData

        public void setUserData​(java.lang.Object key,
                                java.lang.Object value)
        Specified by:
        setUserData in interface Transport
      • registerSelectHandling

        private void registerSelectHandling()
      • setTrace

        public void setTrace​(boolean on)
        Specified by:
        setTrace in interface Transport