class SocketChannelStream extends java.lang.Object implements Stream
| Modifier and Type | Field and Description |
|---|---|
private ServerAddress |
address |
private BufferProvider |
bufferProvider |
private boolean |
isClosed |
private SocketSettings |
settings |
private java.nio.channels.SocketChannel |
socketChannel |
private SslSettings |
sslSettings |
| Constructor and Description |
|---|
SocketChannelStream(ServerAddress address,
SocketSettings settings,
SslSettings sslSettings,
BufferProvider bufferProvider) |
| 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.
|
(package private) SocketSettings |
getSettings()
Get the settings for this socket.
|
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.
|
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 address
private final SocketSettings settings
private final SslSettings sslSettings
private final BufferProvider bufferProvider
private volatile java.nio.channels.SocketChannel socketChannel
private volatile boolean isClosed
public SocketChannelStream(ServerAddress address, SocketSettings settings, SslSettings sslSettings, BufferProvider bufferProvider)
public void open()
throws java.io.IOException
Streampublic ByteBuf getBuffer(int size)
BufferProvidergetBuffer in interface BufferProvidersize - the size required for the bufferpublic void write(java.util.List<ByteBuf> buffers) throws java.io.IOException
Streampublic ByteBuf read(int numBytes) throws java.io.IOException
Streampublic void openAsync(AsyncCompletionHandler<java.lang.Void> handler)
Streampublic void writeAsync(java.util.List<ByteBuf> buffers, AsyncCompletionHandler<java.lang.Void> handler)
StreamwriteAsync in interface Streambuffers - the buffers to writehandler - invoked when the read operation has completedpublic void readAsync(int numBytes,
AsyncCompletionHandler<ByteBuf> handler)
Streampublic ServerAddress getAddress()
StreamgetAddress in interface StreamSocketSettings getSettings()
public void close()
Stream