Package org.apache.tomcat.util.net
Class Nio2Channel
java.lang.Object
org.apache.tomcat.util.net.Nio2Channel
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- AsynchronousByteChannel,- AsynchronousChannel,- Channel
- Direct Known Subclasses:
- SecureNio2Channel
Base class for a SocketChannel wrapper used by the endpoint.
 This way, logic for an SSL socket channel remains the same as for
 a non SSL, making sure we don't need to code for any exception cases.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final SocketBufferHandlerprotected static final ByteBufferprotected AsynchronousSocketChannelprotected SocketWrapperBase<Nio2Channel>
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Closes this channel.voidclose(boolean force) Close the connection.flush()voidfree()Free the channel memoryprotected ApplicationBufferHandlerintPerforms SSL handshake hence is a no-op for the non-secure implementation.booleanbooleanbooleanisOpen()Tells whether or not this channel is open.read(ByteBuffer dst) <A> voidread(ByteBuffer[] dsts, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long, ? super A> handler) <A> voidread(ByteBuffer dst, long timeout, TimeUnit unit, A attachment, CompletionHandler<Integer, ? super A> handler) <A> voidread(ByteBuffer dst, A attachment, CompletionHandler<Integer, ? super A> handler) voidreset(AsynchronousSocketChannel channel, SocketWrapperBase<Nio2Channel> socketWrapper) Reset the channel.voidtoString()write(ByteBuffer src) <A> voidwrite(ByteBuffer[] srcs, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long, ? super A> handler) <A> voidwrite(ByteBuffer src, long timeout, TimeUnit unit, A attachment, CompletionHandler<Integer, ? super A> handler) <A> voidwrite(ByteBuffer src, A attachment, CompletionHandler<Integer, ? super A> handler) 
- 
Field Details- 
emptyBuf
- 
bufHandler
- 
sc
- 
socketWrapper
 
- 
- 
Constructor Details- 
Nio2Channel
 
- 
- 
Method Details- 
resetpublic void reset(AsynchronousSocketChannel channel, SocketWrapperBase<Nio2Channel> socketWrapper) throws IOException Reset the channel.- Parameters:
- channel- The new async channel to associate with this NIO2 channel
- socketWrapper- The new socket to associate with this NIO2 channel
- Throws:
- IOException- If a problem was encountered resetting the channel
 
- 
freepublic void free()Free the channel memory
- 
closeCloses this channel.- Specified by:
- closein interface- AsynchronousChannel
- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Channel
- Specified by:
- closein interface- Closeable
- Throws:
- IOException- If an I/O error occurs
 
- 
closeClose the connection.- Parameters:
- force- Should the underlying socket be forcibly closed?
- Throws:
- IOException- If closing the secure channel fails.
 
- 
isOpenpublic boolean isOpen()Tells whether or not this channel is open.
- 
getBufHandler
- 
getIOChannel
- 
isClosingpublic boolean isClosing()
- 
isHandshakeCompletepublic boolean isHandshakeComplete()
- 
handshakePerforms SSL handshake hence is a no-op for the non-secure implementation.- Returns:
- Always returns zero
- Throws:
- IOException- Never for non-secure channel
 
- 
toString
- 
read- Specified by:
- readin interface- AsynchronousByteChannel
 
- 
read- Specified by:
- readin interface- AsynchronousByteChannel
 
- 
readpublic <A> void read(ByteBuffer dst, long timeout, TimeUnit unit, A attachment, CompletionHandler<Integer, ? super A> handler) 
- 
readpublic <A> void read(ByteBuffer[] dsts, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long, ? super A> handler) 
- 
write- Specified by:
- writein interface- AsynchronousByteChannel
 
- 
write- Specified by:
- writein interface- AsynchronousByteChannel
 
- 
writepublic <A> void write(ByteBuffer src, long timeout, TimeUnit unit, A attachment, CompletionHandler<Integer, ? super A> handler) 
- 
writepublic <A> void write(ByteBuffer[] srcs, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long, ? super A> handler) 
- 
flush
- 
setAppReadBufHandler
- 
getAppReadBufHandler
 
-