Class MessageOutputStream

  • All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable

    class MessageOutputStream
    extends OutputStream
    A stream that we can shove data into that fires off those bytes on flush or when the buffer is full. It also blocks according to the data receiver's needs.

    MessageOutputStream -> ConnectionDataReceiver -> Connection -> PacketQueue -> I2PSession

    • Method Detail

      • setWriteTimeout

        public void setWriteTimeout​(int ms)
      • getWriteTimeout

        public int getWriteTimeout()
      • setBufferSize

        public void setBufferSize​(int size)
        Caller should enforce a sane minimum.
        Parameters:
        size - must be greater than 0, and smaller than or equal to bufSize in constructor
      • flush

        public void flush()
                   throws IOException
        Flush the data already queued up, blocking only if the outbound window is full. Prior to 0.8.1, this blocked until "delivered". "Delivered" meant "received an ACK from the far end", which is not the commom implementation of flush(), and really hurt the performance of i2psnark, which flush()ed frequently. Calling flush() would cause a complete window stall. As of 0.8.1, only wait for accept into the streaming output queue. This will speed up snark significantly, and allow us to flush() the initial data in I2PTunnelRunner, saving 250 ms.
        Specified by:
        flush in interface Flushable
        Overrides:
        flush in class OutputStream
        Throws:
        IOException - if the write fails
      • closeInternal

        public void closeInternal()
        nonblocking close - Only for use inside package
      • getClosed

        public boolean getClosed()
      • streamErrorOccurred

        void streamErrorOccurred​(IOException ioe)
      • destroy

        void destroy()