final class AsynchronousSocketChannelStream extends java.lang.Object implements Stream
Modifier and Type | Class and Description |
---|---|
private class |
AsynchronousSocketChannelStream.AsyncWritableByteChannelAdapter |
private static class |
AsynchronousSocketChannelStream.BaseCompletionHandler<T,V,A> |
private class |
AsynchronousSocketChannelStream.BasicCompletionHandler |
private class |
AsynchronousSocketChannelStream.OpenCompletionHandler |
Modifier and Type | Field and Description |
---|---|
private BufferProvider |
bufferProvider |
private java.nio.channels.AsynchronousSocketChannel |
channel |
private java.nio.channels.AsynchronousChannelGroup |
group |
private boolean |
isClosed |
private ServerAddress |
serverAddress |
private SocketSettings |
settings |
Constructor and Description |
---|
AsynchronousSocketChannelStream(ServerAddress serverAddress,
SocketSettings settings,
BufferProvider bufferProvider,
java.nio.channels.AsynchronousChannelGroup group) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the connection.
|
ServerAddress |
getAddress()
The address that this stream is connected to.
|
ByteBuf |
getBuffer(int size)
Gets a buffer with the givens capacity.
|
java.nio.channels.AsynchronousChannelGroup |
getGroup() |
ServerAddress |
getServerAddress() |
SocketSettings |
getSettings() |
boolean |
isClosed()
Returns the closed state of the connection
|
void |
open()
Open the stream.
|
void |
openAsync(AsyncCompletionHandler<java.lang.Void> handler)
Open the stream asynchronously.
|
private void |
pipeOneBuffer(AsyncWritableByteChannel byteChannel,
ByteBuf byteBuffer,
AsyncCompletionHandler<java.lang.Void> outerHandler) |
ByteBuf |
read(int numBytes)
Read from the stream, blocking until the requested number of bytes have been read.
|
void |
readAsync(int numBytes,
AsyncCompletionHandler<ByteBuf> handler)
Read from the stream, asynchronously.
|
void |
write(java.util.List<ByteBuf> buffers)
Write each buffer in the list to the stream in order, blocking until all are completely written.
|
void |
writeAsync(java.util.List<ByteBuf> buffers,
AsyncCompletionHandler<java.lang.Void> handler)
Write each buffer in the list to the stream in order, asynchronously.
|
private final ServerAddress serverAddress
private final SocketSettings settings
private final BufferProvider bufferProvider
private final java.nio.channels.AsynchronousChannelGroup group
private volatile java.nio.channels.AsynchronousSocketChannel channel
private volatile boolean isClosed
AsynchronousSocketChannelStream(ServerAddress serverAddress, SocketSettings settings, BufferProvider bufferProvider, java.nio.channels.AsynchronousChannelGroup group)
public ByteBuf getBuffer(int size)
BufferProvider
getBuffer
in interface BufferProvider
size
- the size required for the bufferpublic void open() throws java.io.IOException
Stream
public void openAsync(AsyncCompletionHandler<java.lang.Void> handler)
Stream
public void write(java.util.List<ByteBuf> buffers) throws java.io.IOException
Stream
public ByteBuf read(int numBytes) throws java.io.IOException
Stream
public void writeAsync(java.util.List<ByteBuf> buffers, AsyncCompletionHandler<java.lang.Void> handler)
Stream
writeAsync
in interface Stream
buffers
- the buffers to writehandler
- invoked when the read operation has completedpublic void readAsync(int numBytes, AsyncCompletionHandler<ByteBuf> handler)
Stream
public ServerAddress getAddress()
Stream
getAddress
in interface Stream
public boolean isClosed()
Stream
public ServerAddress getServerAddress()
public SocketSettings getSettings()
public java.nio.channels.AsynchronousChannelGroup getGroup()
private void pipeOneBuffer(AsyncWritableByteChannel byteChannel, ByteBuf byteBuffer, AsyncCompletionHandler<java.lang.Void> outerHandler)