Package org.simpleframework.transport
Class SocketBufferWriter
- java.lang.Object
-
- org.simpleframework.transport.SocketBufferWriter
-
class SocketBufferWriter extends java.lang.ObjectTheSocketBufferWriteris 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 SocketFlusherflusherThis is the flusher that is used to asynchronously flush.private SocketBufferwriterThis 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 theSocketBufferWriterobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()This is used to close the writer and the underlying socket.voidflush()This method is used to flush all of the queued buffers to the client.voidwrite(java.nio.ByteBuffer buffer)This method is used to deliver the provided buffer of bytes to the underlying transport.
-
-
-
Field Detail
-
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 Detail
-
SocketBufferWriter
public SocketBufferWriter(Socket socket, Reactor reactor, int buffer, int threshold) throws java.io.IOException
Constructor for theSocketBufferWriterobject. 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:
java.io.IOException
-
-
Method Detail
-
write
public void write(java.nio.ByteBuffer buffer) throws java.io.IOExceptionThis 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:
java.io.IOException
-
flush
public void flush() throws java.io.IOExceptionThis 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:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionThis 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:
java.io.IOException
-
-