Package org.simpleframework.transport
Class SocketBufferWriter
java.lang.Object
org.simpleframework.transport.SocketBufferWriter
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
FieldsModifier and TypeFieldDescriptionprivate 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
ConstructorsConstructorDescriptionSocketBufferWriter
(Socket socket, Reactor reactor, int buffer, int threshold) Constructor for theSocketBufferWriter
object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
This is used to close the writer and the underlying socket.void
flush()
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.
-
Field Details
-
flusher
This is the flusher that is used to asynchronously flush. -
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 theSocketBufferWriter
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 toreactor
- this is the writer used to scheduler writesbuffer
- this is the initial size of the output bufferthreshold
- this is the maximum size of the buffer- Throws:
IOException
-
-
Method Details
-
write
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
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
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
-