Class SocketBufferWriter

java.lang.Object
org.simpleframework.transport.SocketBufferWriter

class SocketBufferWriter extends Object
The SocketBufferWriter is used to represent the means to write buffers to an underlying transport. This manages all of the selection required to determine if the socket is write ready. If the buffer to be written is to block then this will wait until all queue buffers are fully written.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final SocketFlusher
    This is the flusher that is used to asynchronously flush.
    private final SocketBuffer
    This is the writer that is used to queue the buffers.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SocketBufferWriter(Socket socket, Reactor reactor, int buffer, int threshold)
    Constructor for the SocketBufferWriter object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This is used to close the writer and the underlying socket.
    void
    This method is used to flush all of the queued buffers to the client.
    void
    write(ByteBuffer buffer)
    This method is used to deliver the provided buffer of bytes to the underlying transport.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • flusher

      private final SocketFlusher flusher
      This is the flusher that is used to asynchronously flush.
    • writer

      private final SocketBuffer writer
      This is the writer that is used to queue the buffers.
  • Constructor Details

    • SocketBufferWriter

      public SocketBufferWriter(Socket socket, Reactor reactor, int buffer, int threshold) throws IOException
      Constructor for the SocketBufferWriter object. This is used to create a writer that can write buffers to the socket in such a way that it write either asynchronously or block the calling thread until such time as the buffers are written.
      Parameters:
      socket - this is the pipeline that this writes to
      reactor - this is the writer used to scheduler writes
      buffer - this is the initial size of the output buffer
      threshold - this is the maximum size of the buffer
      Throws:
      IOException
  • Method Details

    • write

      public void write(ByteBuffer buffer) throws IOException
      This method is used to deliver the provided buffer of bytes to the underlying transport. This will not modify the data that is to be written, this will simply queue the buffers in the order that they are provided.
      Parameters:
      buffer - this is the array of bytes to send to the client
      Throws:
      IOException
    • flush

      public void flush() throws IOException
      This method is used to flush all of the queued buffers to the client. This method will not block but will simply flush any data to the underlying transport. Internally the data will be queued for delivery to the connected entity.
      Throws:
      IOException
    • close

      public void close() throws IOException
      This is used to close the writer and the underlying socket. If a close is performed on the writer then no more bytes can be read from or written to the writer and the client will receive a connection close on their side.
      Throws:
      IOException