public class Nio2Channel extends Object implements AsynchronousByteChannel
Modifier and Type | Field and Description |
---|---|
protected SocketBufferHandler |
bufHandler |
protected static ByteBuffer |
emptyBuf |
protected AsynchronousSocketChannel |
sc |
protected SocketWrapperBase<Nio2Channel> |
socket |
Constructor and Description |
---|
Nio2Channel(SocketBufferHandler bufHandler) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this channel.
|
void |
close(boolean force)
Close the connection.
|
Future<Boolean> |
flush() |
void |
free()
Free the channel memory
|
SocketBufferHandler |
getBufHandler() |
AsynchronousSocketChannel |
getIOChannel() |
SocketWrapperBase<Nio2Channel> |
getSocket() |
int |
handshake()
Performs SSL handshake hence is a no-op for the non-secure
implementation.
|
boolean |
isClosing() |
boolean |
isHandshakeComplete() |
boolean |
isOpen()
Tells whether or not this channel is open.
|
Future<Integer> |
read(ByteBuffer dst) |
<A> void |
read(ByteBuffer[] dsts,
int offset,
int length,
long timeout,
TimeUnit unit,
A attachment,
CompletionHandler<Long,? super A> handler) |
<A> void |
read(ByteBuffer dst,
A attachment,
CompletionHandler<Integer,? super A> handler) |
<A> void |
read(ByteBuffer dst,
long timeout,
TimeUnit unit,
A attachment,
CompletionHandler<Integer,? super A> handler) |
void |
reset(AsynchronousSocketChannel channel,
SocketWrapperBase<Nio2Channel> socket)
Reset the channel.
|
String |
toString() |
Future<Integer> |
write(ByteBuffer src) |
<A> void |
write(ByteBuffer[] srcs,
int offset,
int length,
long timeout,
TimeUnit unit,
A attachment,
CompletionHandler<Long,? super A> handler) |
<A> void |
write(ByteBuffer src,
A attachment,
CompletionHandler<Integer,? super A> handler) |
<A> void |
write(ByteBuffer src,
long timeout,
TimeUnit unit,
A attachment,
CompletionHandler<Integer,? super A> handler) |
protected static final ByteBuffer emptyBuf
protected AsynchronousSocketChannel sc
protected SocketWrapperBase<Nio2Channel> socket
protected final SocketBufferHandler bufHandler
public Nio2Channel(SocketBufferHandler bufHandler)
public void reset(AsynchronousSocketChannel channel, SocketWrapperBase<Nio2Channel> socket) throws IOException
channel
- The new async channel to associate with this NIO2 channelsocket
- The new socket to associate with this NIO2 channelIOException
- If a problem was encountered resetting the channelpublic void free()
public SocketWrapperBase<Nio2Channel> getSocket()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in interface AsynchronousChannel
close
in interface Channel
IOException
- If an I/O error occurspublic void close(boolean force) throws IOException
force
- Should the underlying socket be forcibly closed?IOException
- If closing the secure channel fails.public boolean isOpen()
public SocketBufferHandler getBufHandler()
public AsynchronousSocketChannel getIOChannel()
public boolean isClosing()
public boolean isHandshakeComplete()
public int handshake() throws IOException
IOException
- Never for non-secure channelpublic Future<Integer> read(ByteBuffer dst)
read
in interface AsynchronousByteChannel
public <A> void read(ByteBuffer dst, A attachment, CompletionHandler<Integer,? super A> handler)
read
in interface AsynchronousByteChannel
public <A> void read(ByteBuffer dst, long timeout, TimeUnit unit, A attachment, CompletionHandler<Integer,? super A> handler)
public <A> void read(ByteBuffer[] dsts, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long,? super A> handler)
public Future<Integer> write(ByteBuffer src)
write
in interface AsynchronousByteChannel
public <A> void write(ByteBuffer src, A attachment, CompletionHandler<Integer,? super A> handler)
write
in interface AsynchronousByteChannel
public <A> void write(ByteBuffer src, long timeout, TimeUnit unit, A attachment, CompletionHandler<Integer,? super A> handler)
public <A> void write(ByteBuffer[] srcs, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long,? super A> handler)
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.