Class SocketWrapperBase<E>
- java.lang.Object
- 
- org.apache.tomcat.util.net.SocketWrapperBase<E>
 
- 
- Direct Known Subclasses:
- AprEndpoint.AprSocketWrapper,- Nio2Endpoint.Nio2SocketWrapper,- NioEndpoint.NioSocketWrapper
 
 public abstract class SocketWrapperBase<E> extends java.lang.Object
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classSocketWrapperBase.BlockingModestatic interfaceSocketWrapperBase.CompletionCheckstatic classSocketWrapperBase.CompletionHandlerCallstatic classSocketWrapperBase.CompletionStateprotected classSocketWrapperBase.OperationState<A>Internal state tracker for vectored operations.protected classSocketWrapperBase.VectoredIOCompletionHandler<A>Completion handler for vectored operations.
 - 
Field SummaryFields Modifier and Type Field Description protected intbufferedWriteSizeThe max size of the individual buffered write buffersprotected java.util.concurrent.atomic.AtomicBooleanclosedstatic SocketWrapperBase.CompletionCheckCOMPLETE_READThis utility CompletionCheck will cause the completion handler to be called once the given buffers are full.static SocketWrapperBase.CompletionCheckCOMPLETE_READ_WITH_COMPLETIONThis utility CompletionCheck will cause the completion handler to be called once the given buffers are full.static SocketWrapperBase.CompletionCheckCOMPLETE_WRITEThis utility CompletionCheck will cause the write to fully write all remaining data.static SocketWrapperBase.CompletionCheckCOMPLETE_WRITE_WITH_COMPLETIONThis utility CompletionCheck will cause the write to fully write all remaining data.protected java.lang.StringlocalAddrprotected java.lang.StringlocalNameprotected intlocalPortprotected WriteBuffernonBlockingWriteBufferAdditional buffer used for non-blocking writes.protected java.io.IOExceptionpreviousIOExceptionstatic SocketWrapperBase.CompletionCheckREAD_DATAThis utility CompletionCheck will cause the completion handler to be called once some data has been read.protected SocketWrapperBase.OperationState<?>readOperationprotected java.util.concurrent.SemaphorereadPendingprotected java.lang.StringremoteAddrprotected java.lang.StringremoteHostprotected intremotePortprotected static StringManagersmprotected SocketBufferHandlersocketBufferHandlerThe buffers used for communicating with the socket.protected SocketWrapperBase.OperationState<?>writeOperationprotected java.util.concurrent.SemaphorewritePending
 - 
Constructor SummaryConstructors Constructor Description SocketWrapperBase(E socket, AbstractEndpoint<E,?> endpoint)
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanawaitReadComplete(long timeout, java.util.concurrent.TimeUnit unit)Deprecated.booleanawaitWriteComplete(long timeout, java.util.concurrent.TimeUnit unit)Deprecated.protected static booleanbuffersArrayHasRemaining(java.nio.ByteBuffer[] buffers, int offset, int length)booleancanWrite()voidcheckError()voidclose()Close the socket wrapper.abstract SendfileDataBasecreateSendfileData(java.lang.String filename, long pos, long length)intdecrementKeepAlive()abstract voiddoClientAuth(SSLSupport sslSupport)Require the client to perform CLIENT-CERT authentication if it hasn't already done so.protected abstract voiddoClose()Perform the actual close.protected voiddoWrite(boolean block)Write the contents of the socketWriteBuffer to the socket.protected abstract voiddoWrite(boolean block, java.nio.ByteBuffer from)Write the contents of the ByteBuffer to the socket.voidexecute(java.lang.Runnable runnable)Transfers processing to a container thread.booleanflush(boolean block)Writes as much data as possible from any that remains in the buffers.protected voidflushBlocking()Writes all remaining data from the buffers and blocks until the write is complete.protected abstract booleanflushNonBlocking()Writes as much data as possible from any that remains in the buffers.java.lang.ObjectgetCurrentProcessor()AbstractEndpoint<E,?>getEndpoint()java.io.IOExceptiongetError()java.lang.StringgetLocalAddr()java.lang.StringgetLocalName()intgetLocalPort()java.lang.StringgetNegotiatedProtocol()longgetReadTimeout()java.lang.StringgetRemoteAddr()java.lang.StringgetRemoteHost()intgetRemotePort()EgetSocket()SocketBufferHandlergetSocketBufferHandler()abstract SSLSupportgetSslSupport(java.lang.String clientCertProvider)longgetWriteTimeout()booleanhasAsyncIO()Allows using NIO2 style read/write.booleanhasDataToRead()booleanhasDataToWrite()booleanhasPerOperationTimeout()Allows indicating if the connector supports per operation timeout.booleanisClosed()booleanisReadPending()Allows checking if an asynchronous read operation is currently pending.abstract booleanisReadyForRead()booleanisReadyForWrite()Checks to see if there are any writes pending and if there are callsregisterWriteInterest()to trigger a callback once the pending writes have completed.booleanisSecure()Deprecated.Unused.booleanisUpgraded()Deprecated.Unused.booleanisWritePending()Allows checking if an asynchronous write operation is currently pending.booleanneedSemaphores()Allows indicating if the connector needs semaphores.protected abstract <A> SocketWrapperBase.OperationState<A>newOperationState(boolean read, java.nio.ByteBuffer[] buffers, int offset, int length, SocketWrapperBase.BlockingMode block, long timeout, java.util.concurrent.TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler, java.util.concurrent.Semaphore semaphore, SocketWrapperBase.VectoredIOCompletionHandler<A> completion)protected abstract voidpopulateLocalAddr()protected abstract voidpopulateLocalName()protected abstract voidpopulateLocalPort()protected intpopulateReadBuffer(byte[] b, int off, int len)protected intpopulateReadBuffer(java.nio.ByteBuffer to)protected abstract voidpopulateRemoteAddr()protected abstract voidpopulateRemoteHost()protected abstract voidpopulateRemotePort()abstract SendfileStateprocessSendfile(SendfileDataBase sendfileData)Starts the sendfile process.voidprocessSocket(SocketEvent socketStatus, boolean dispatch)abstract intread(boolean block, byte[] b, int off, int len)abstract intread(boolean block, java.nio.ByteBuffer to)<A> SocketWrapperBase.CompletionStateread(long timeout, java.util.concurrent.TimeUnit unit, A attachment, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler, java.nio.ByteBuffer... dsts)Scatter read.<A> SocketWrapperBase.CompletionStateread(java.nio.ByteBuffer[] dsts, int offset, int length, SocketWrapperBase.BlockingMode block, long timeout, java.util.concurrent.TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler)Scatter read.<A> SocketWrapperBase.CompletionStateread(SocketWrapperBase.BlockingMode block, long timeout, java.util.concurrent.TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler, java.nio.ByteBuffer... dsts)Scatter read.abstract voidregisterReadInterest()abstract voidregisterWriteInterest()protected voidreset(E closedSocket)abstract voidsetAppReadBufHandler(ApplicationBufferHandler handler)voidsetCurrentProcessor(java.lang.Object currentProcessor)voidsetError(java.io.IOException error)voidsetKeepAliveLeft(int keepAliveLeft)voidsetNegotiatedProtocol(java.lang.String negotiatedProtocol)voidsetReadTimeout(long readTimeout)Set the timeout for reading.voidsetSecure(boolean secure)Deprecated.Unused.voidsetUpgraded(boolean upgraded)Deprecated.Unused.voidsetWriteTimeout(long writeTimeout)Set the timeout for writing.java.lang.ObjecttakeCurrentProcessor()java.lang.StringtoString()Overridden for debug purposes.protected static inttransfer(byte[] from, int offset, int length, java.nio.ByteBuffer to)protected static inttransfer(java.nio.ByteBuffer from, java.nio.ByteBuffer to)voidunRead(java.nio.ByteBuffer returnedInput)Return input that has been read to the input buffer for re-reading by the correct component.protected <A> SocketWrapperBase.CompletionStatevectoredOperation(boolean read, java.nio.ByteBuffer[] buffers, int offset, int length, SocketWrapperBase.BlockingMode block, long timeout, java.util.concurrent.TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler)Vectored operation.voidwrite(boolean block, byte[] buf, int off, int len)Writes the provided data to the socket write buffer.voidwrite(boolean block, java.nio.ByteBuffer from)Writes the provided data to the socket write buffer.<A> SocketWrapperBase.CompletionStatewrite(long timeout, java.util.concurrent.TimeUnit unit, A attachment, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler, java.nio.ByteBuffer... srcs)Gather write.<A> SocketWrapperBase.CompletionStatewrite(java.nio.ByteBuffer[] srcs, int offset, int length, SocketWrapperBase.BlockingMode block, long timeout, java.util.concurrent.TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler)Gather write.<A> SocketWrapperBase.CompletionStatewrite(SocketWrapperBase.BlockingMode block, long timeout, java.util.concurrent.TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler, java.nio.ByteBuffer... srcs)Gather write.protected voidwriteBlocking(byte[] buf, int off, int len)Writes the provided data to the socket write buffer.protected voidwriteBlocking(java.nio.ByteBuffer from)Writes the provided data to the socket write buffer.protected voidwriteNonBlocking(byte[] buf, int off, int len)Transfers the data to the socket write buffer (writing that data to the socket if the buffer fills up using a non-blocking write) until either all the data has been transferred and space remains in the socket write buffer or a non-blocking write leaves data in the socket write buffer.protected voidwriteNonBlocking(java.nio.ByteBuffer from)Transfers the data to the socket write buffer (writing that data to the socket if the buffer fills up using a non-blocking write) until either all the data has been transferred and space remains in the socket write buffer or a non-blocking write leaves data in the socket write buffer.protected voidwriteNonBlockingInternal(java.nio.ByteBuffer from)Separate method so it can be re-used by the socket write buffer to write data to the network
 
- 
- 
- 
Field Detail- 
smprotected static final StringManager sm 
 - 
closedprotected final java.util.concurrent.atomic.AtomicBoolean closed 
 - 
previousIOExceptionprotected volatile java.io.IOException previousIOException 
 - 
localAddrprotected java.lang.String localAddr 
 - 
localNameprotected java.lang.String localName 
 - 
localPortprotected int localPort 
 - 
remoteAddrprotected java.lang.String remoteAddr 
 - 
remoteHostprotected java.lang.String remoteHost 
 - 
remotePortprotected int remotePort 
 - 
socketBufferHandlerprotected volatile SocketBufferHandler socketBufferHandler The buffers used for communicating with the socket.
 - 
bufferedWriteSizeprotected int bufferedWriteSize The max size of the individual buffered write buffers
 - 
nonBlockingWriteBufferprotected final WriteBuffer nonBlockingWriteBuffer Additional buffer used for non-blocking writes. Non-blocking writes need to return immediately even if the data cannot be written immediately but the socket buffer may not be big enough to hold all of the unwritten data. This structure provides an additional buffer to hold the data until it can be written. Not that while the Servlet API only allows one non-blocking write at a time, due to buffering and the possible need to write HTTP headers, this layer may see multiple writes.
 - 
readPendingprotected final java.util.concurrent.Semaphore readPending 
 - 
readOperationprotected volatile SocketWrapperBase.OperationState<?> readOperation 
 - 
writePendingprotected final java.util.concurrent.Semaphore writePending 
 - 
writeOperationprotected volatile SocketWrapperBase.OperationState<?> writeOperation 
 - 
COMPLETE_WRITEpublic static final SocketWrapperBase.CompletionCheck COMPLETE_WRITE This utility CompletionCheck will cause the write to fully write all remaining data. If the operation completes inline, the completion handler will not be called.
 - 
COMPLETE_WRITE_WITH_COMPLETIONpublic static final SocketWrapperBase.CompletionCheck COMPLETE_WRITE_WITH_COMPLETION This utility CompletionCheck will cause the write to fully write all remaining data. The completion handler will then be called.
 - 
READ_DATApublic static final SocketWrapperBase.CompletionCheck READ_DATA This utility CompletionCheck will cause the completion handler to be called once some data has been read. If the operation completes inline, the completion handler will not be called.
 - 
COMPLETE_READ_WITH_COMPLETIONpublic static final SocketWrapperBase.CompletionCheck COMPLETE_READ_WITH_COMPLETION This utility CompletionCheck will cause the completion handler to be called once the given buffers are full. The completion handler will then be called.
 - 
COMPLETE_READpublic static final SocketWrapperBase.CompletionCheck COMPLETE_READ This utility CompletionCheck will cause the completion handler to be called once the given buffers are full. If the operation completes inline, the completion handler will not be called.
 
- 
 - 
Constructor Detail- 
SocketWrapperBasepublic SocketWrapperBase(E socket, AbstractEndpoint<E,?> endpoint) 
 
- 
 - 
Method Detail- 
getSocketpublic E getSocket() 
 - 
resetprotected void reset(E closedSocket) 
 - 
getEndpointpublic AbstractEndpoint<E,?> getEndpoint() 
 - 
getCurrentProcessorpublic java.lang.Object getCurrentProcessor() 
 - 
setCurrentProcessorpublic void setCurrentProcessor(java.lang.Object currentProcessor) 
 - 
takeCurrentProcessorpublic java.lang.Object takeCurrentProcessor() 
 - 
executepublic void execute(java.lang.Runnable runnable) Transfers processing to a container thread.- Parameters:
- runnable- The actions to process on a container thread
- Throws:
- java.util.concurrent.RejectedExecutionException- If the runnable cannot be executed
 
 - 
getErrorpublic java.io.IOException getError() 
 - 
setErrorpublic void setError(java.io.IOException error) 
 - 
checkErrorpublic void checkError() throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
isUpgraded@Deprecated public boolean isUpgraded() Deprecated.Unused. Will be removed in Tomcat 10.- Returns:
- trueif the connection has been upgraded.
 
 - 
setUpgraded@Deprecated public void setUpgraded(boolean upgraded) Deprecated.Unused. Will be removed in Tomcat 10.- Parameters:
- upgraded-- trueif the connection has been upgraded.
 
 - 
isSecure@Deprecated public boolean isSecure() Deprecated.Unused. Will be removed in Tomcat 10.- Returns:
- trueif the connection uses TLS
 
 - 
setSecure@Deprecated public void setSecure(boolean secure) Deprecated.Unused. Will be removed in Tomcat 10.- Parameters:
- secure-- trueif the connection uses TLS
 
 - 
getNegotiatedProtocolpublic java.lang.String getNegotiatedProtocol() 
 - 
setNegotiatedProtocolpublic void setNegotiatedProtocol(java.lang.String negotiatedProtocol) 
 - 
setReadTimeoutpublic void setReadTimeout(long readTimeout) Set the timeout for reading. Values of zero or less will be changed to -1.- Parameters:
- readTimeout- The timeout in milliseconds. A value of -1 indicates an infinite timeout.
 
 - 
getReadTimeoutpublic long getReadTimeout() 
 - 
setWriteTimeoutpublic void setWriteTimeout(long writeTimeout) Set the timeout for writing. Values of zero or less will be changed to -1.- Parameters:
- writeTimeout- The timeout in milliseconds. A value of zero or less indicates an infinite timeout.
 
 - 
getWriteTimeoutpublic long getWriteTimeout() 
 - 
setKeepAliveLeftpublic void setKeepAliveLeft(int keepAliveLeft) 
 - 
decrementKeepAlivepublic int decrementKeepAlive() 
 - 
getRemoteHostpublic java.lang.String getRemoteHost() 
 - 
populateRemoteHostprotected abstract void populateRemoteHost() 
 - 
getRemoteAddrpublic java.lang.String getRemoteAddr() 
 - 
populateRemoteAddrprotected abstract void populateRemoteAddr() 
 - 
getRemotePortpublic int getRemotePort() 
 - 
populateRemotePortprotected abstract void populateRemotePort() 
 - 
getLocalNamepublic java.lang.String getLocalName() 
 - 
populateLocalNameprotected abstract void populateLocalName() 
 - 
getLocalAddrpublic java.lang.String getLocalAddr() 
 - 
populateLocalAddrprotected abstract void populateLocalAddr() 
 - 
getLocalPortpublic int getLocalPort() 
 - 
populateLocalPortprotected abstract void populateLocalPort() 
 - 
getSocketBufferHandlerpublic SocketBufferHandler getSocketBufferHandler() 
 - 
hasDataToReadpublic boolean hasDataToRead() 
 - 
hasDataToWritepublic boolean hasDataToWrite() 
 - 
isReadyForWritepublic boolean isReadyForWrite() Checks to see if there are any writes pending and if there are callsregisterWriteInterest()to trigger a callback once the pending writes have completed.Note: Once this method has returned falseit MUST NOT be called again until the pending write has completed and the callback has been fired. TODO: ModifyregisterWriteInterest()so the above restriction is enforced there rather than relying on the caller.- Returns:
- trueif no writes are pending and data can be written otherwise- false
 
 - 
canWritepublic boolean canWrite() 
 - 
toStringpublic java.lang.String toString() Overridden for debug purposes. No guarantees are made about the format of this message which may vary significantly between point releases.- Overrides:
- toStringin class- java.lang.Object
 
 - 
readpublic abstract int read(boolean block, byte[] b, int off, int len) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
readpublic abstract int read(boolean block, java.nio.ByteBuffer to) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
isReadyForReadpublic abstract boolean isReadyForRead() throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
setAppReadBufHandlerpublic abstract void setAppReadBufHandler(ApplicationBufferHandler handler) 
 - 
populateReadBufferprotected int populateReadBuffer(byte[] b, int off, int len)
 - 
populateReadBufferprotected int populateReadBuffer(java.nio.ByteBuffer to) 
 - 
unReadpublic void unRead(java.nio.ByteBuffer returnedInput) Return input that has been read to the input buffer for re-reading by the correct component. There are times when a component may read more data than it needs before it passes control to another component. One example of this is during HTTP upgrade. If an (arguably misbehaving client) sends data associated with the upgraded protocol before the HTTP upgrade completes, the HTTP handler may read it. This method provides a way for that data to be returned so it can be processed by the correct component.- Parameters:
- returnedInput- The input to return to the input buffer.
 
 - 
closepublic void close() Close the socket wrapper.
 - 
doCloseprotected abstract void doClose() Perform the actual close. The closed atomic boolean guarantees this will be called only once per wrapper.
 - 
isClosedpublic boolean isClosed() - Returns:
- true if the wrapper has been closed
 
 - 
writepublic final void write(boolean block, byte[] buf, int off, int len) throws java.io.IOExceptionWrites the provided data to the socket write buffer. If the socket write buffer fills during the write, the content of the socket write buffer is written to the network and this method starts to fill the socket write buffer again. Depending on the size of the data to write, there may be multiple writes to the network.Non-blocking writes must return immediately and the byte array holding the data to be written must be immediately available for re-use. It may not be possible to write sufficient data to the network to allow this to happen. In this case data that cannot be written to the network and cannot be held by the socket buffer is stored in the non-blocking write buffer. Note: There is an implementation assumption that, before switching from non-blocking writes to blocking writes, any data remaining in the non-blocking write buffer will have been written to the network. - Parameters:
- block-- trueif a blocking write should be used, otherwise a non-blocking write will be used
- buf- The byte array containing the data to be written
- off- The offset within the byte array of the data to be written
- len- The length of the data to be written
- Throws:
- java.io.IOException- If an IO error occurs during the write
 
 - 
writepublic final void write(boolean block, java.nio.ByteBuffer from) throws java.io.IOExceptionWrites the provided data to the socket write buffer. If the socket write buffer fills during the write, the content of the socket write buffer is written to the network and this method starts to fill the socket write buffer again. Depending on the size of the data to write, there may be multiple writes to the network.Non-blocking writes must return immediately and the ByteBuffer holding the data to be written must be immediately available for re-use. It may not be possible to write sufficient data to the network to allow this to happen. In this case data that cannot be written to the network and cannot be held by the socket buffer is stored in the non-blocking write buffer. Note: There is an implementation assumption that, before switching from non-blocking writes to blocking writes, any data remaining in the non-blocking write buffer will have been written to the network. - Parameters:
- block-- trueif a blocking write should be used, otherwise a non-blocking write will be used
- from- The ByteBuffer containing the data to be written
- Throws:
- java.io.IOException- If an IO error occurs during the write
 
 - 
writeBlockingprotected void writeBlocking(byte[] buf, int off, int len) throws java.io.IOExceptionWrites the provided data to the socket write buffer. If the socket write buffer fills during the write, the content of the socket write buffer is written to the network using a blocking write. Once that blocking write is complete, this method starts to fill the socket write buffer again. Depending on the size of the data to write, there may be multiple writes to the network. On completion of this method there will always be space remaining in the socket write buffer.- Parameters:
- buf- The byte array containing the data to be written
- off- The offset within the byte array of the data to be written
- len- The length of the data to be written
- Throws:
- java.io.IOException- If an IO error occurs during the write
 
 - 
writeBlockingprotected void writeBlocking(java.nio.ByteBuffer from) throws java.io.IOExceptionWrites the provided data to the socket write buffer. If the socket write buffer fills during the write, the content of the socket write buffer is written to the network using a blocking write. Once that blocking write is complete, this method starts to fill the socket write buffer again. Depending on the size of the data to write, there may be multiple writes to the network. On completion of this method there will always be space remaining in the socket write buffer.- Parameters:
- from- The ByteBuffer containing the data to be written
- Throws:
- java.io.IOException- If an IO error occurs during the write
 
 - 
writeNonBlockingprotected void writeNonBlocking(byte[] buf, int off, int len) throws java.io.IOExceptionTransfers the data to the socket write buffer (writing that data to the socket if the buffer fills up using a non-blocking write) until either all the data has been transferred and space remains in the socket write buffer or a non-blocking write leaves data in the socket write buffer. After an incomplete write, any data remaining to be transferred to the socket write buffer will be copied to the socket write buffer. If the remaining data is too big for the socket write buffer, the socket write buffer will be filled and the additional data written to the non-blocking write buffer.- Parameters:
- buf- The byte array containing the data to be written
- off- The offset within the byte array of the data to be written
- len- The length of the data to be written
- Throws:
- java.io.IOException- If an IO error occurs during the write
 
 - 
writeNonBlockingprotected void writeNonBlocking(java.nio.ByteBuffer from) throws java.io.IOExceptionTransfers the data to the socket write buffer (writing that data to the socket if the buffer fills up using a non-blocking write) until either all the data has been transferred and space remains in the socket write buffer or a non-blocking write leaves data in the socket write buffer. After an incomplete write, any data remaining to be transferred to the socket write buffer will be copied to the socket write buffer. If the remaining data is too big for the socket write buffer, the socket write buffer will be filled and the additional data written to the non-blocking write buffer.- Parameters:
- from- The ByteBuffer containing the data to be written
- Throws:
- java.io.IOException- If an IO error occurs during the write
 
 - 
writeNonBlockingInternalprotected void writeNonBlockingInternal(java.nio.ByteBuffer from) throws java.io.IOExceptionSeparate method so it can be re-used by the socket write buffer to write data to the network- Parameters:
- from- The ByteBuffer containing the data to be written
- Throws:
- java.io.IOException- If an IO error occurs during the write
 
 - 
flushpublic boolean flush(boolean block) throws java.io.IOExceptionWrites as much data as possible from any that remains in the buffers.- Parameters:
- block-- trueif a blocking write should be used, otherwise a non-blocking write will be used
- Returns:
- trueif data remains to be flushed after this method completes, otherwise- false. In blocking mode therefore, the return value should always be- false
- Throws:
- java.io.IOException- If an IO error occurs during the write
 
 - 
flushBlockingprotected void flushBlocking() throws java.io.IOExceptionWrites all remaining data from the buffers and blocks until the write is complete.- Throws:
- java.io.IOException- If an IO error occurs during the write
 
 - 
flushNonBlockingprotected abstract boolean flushNonBlocking() throws java.io.IOExceptionWrites as much data as possible from any that remains in the buffers.- Returns:
- trueif data remains to be flushed after this method completes, otherwise- false.
- Throws:
- java.io.IOException- If an IO error occurs during the write
 
 - 
doWriteprotected void doWrite(boolean block) throws java.io.IOExceptionWrite the contents of the socketWriteBuffer to the socket. For blocking writes either then entire contents of the buffer will be written or an IOException will be thrown. Partial blocking writes will not occur.- Parameters:
- block- Should the write be blocking or not?
- Throws:
- java.io.IOException- If an I/O error such as a timeout occurs during the write
 
 - 
doWriteprotected abstract void doWrite(boolean block, java.nio.ByteBuffer from) throws java.io.IOExceptionWrite the contents of the ByteBuffer to the socket. For blocking writes either then entire contents of the buffer will be written or an IOException will be thrown. Partial blocking writes will not occur.- Parameters:
- block- Should the write be blocking or not?
- from- the ByteBuffer containing the data to be written
- Throws:
- java.io.IOException- If an I/O error such as a timeout occurs during the write
 
 - 
processSocketpublic void processSocket(SocketEvent socketStatus, boolean dispatch) 
 - 
registerReadInterestpublic abstract void registerReadInterest() 
 - 
registerWriteInterestpublic abstract void registerWriteInterest() 
 - 
createSendfileDatapublic abstract SendfileDataBase createSendfileData(java.lang.String filename, long pos, long length) 
 - 
processSendfilepublic abstract SendfileState processSendfile(SendfileDataBase sendfileData) Starts the sendfile process. It is expected that if the sendfile process does not complete during this call and does not report an error, that the caller will not add the socket to the poller (or equivalent). That is the responsibility of this method.- Parameters:
- sendfileData- Data representing the file to send
- Returns:
- The state of the sendfile process after the first write.
 
 - 
doClientAuthpublic abstract void doClientAuth(SSLSupport sslSupport) throws java.io.IOException Require the client to perform CLIENT-CERT authentication if it hasn't already done so.- Parameters:
- sslSupport- The SSL/TLS support instance currently being used by the connection that may need updating after the client authentication
- Throws:
- java.io.IOException- If authentication is required then there will be I/O with the client and this exception will be thrown if that goes wrong
 
 - 
getSslSupportpublic abstract SSLSupport getSslSupport(java.lang.String clientCertProvider) 
 - 
hasAsyncIOpublic boolean hasAsyncIO() Allows using NIO2 style read/write.- Returns:
- trueif the connector has the capability enabled
 
 - 
needSemaphorespublic boolean needSemaphores() Allows indicating if the connector needs semaphores.- Returns:
- This default implementation always returns false
 
 - 
hasPerOperationTimeoutpublic boolean hasPerOperationTimeout() Allows indicating if the connector supports per operation timeout.- Returns:
- This default implementation always returns false
 
 - 
isReadPendingpublic boolean isReadPending() Allows checking if an asynchronous read operation is currently pending.- Returns:
- trueif the endpoint supports asynchronous IO and a read operation is being processed asynchronously
 
 - 
isWritePendingpublic boolean isWritePending() Allows checking if an asynchronous write operation is currently pending.- Returns:
- trueif the endpoint supports asynchronous IO and a write operation is being processed asynchronously
 
 - 
awaitReadComplete@Deprecated public boolean awaitReadComplete(long timeout, java.util.concurrent.TimeUnit unit)Deprecated.If an asynchronous read operation is pending, this method will block until the operation completes, or the specified amount of time has passed.- Parameters:
- timeout- The maximum amount of time to wait
- unit- The unit for the timeout
- Returns:
- trueif the read operation is complete,- falseif the operation is still pending and the specified timeout has passed
 
 - 
awaitWriteComplete@Deprecated public boolean awaitWriteComplete(long timeout, java.util.concurrent.TimeUnit unit)Deprecated.If an asynchronous write operation is pending, this method will block until the operation completes, or the specified amount of time has passed.- Parameters:
- timeout- The maximum amount of time to wait
- unit- The unit for the timeout
- Returns:
- trueif the read operation is complete,- falseif the operation is still pending and the specified timeout has passed
 
 - 
readpublic final <A> SocketWrapperBase.CompletionState read(long timeout, java.util.concurrent.TimeUnit unit, A attachment, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler, java.nio.ByteBuffer... dsts) Scatter read. The completion handler will be called once some data has been read or an error occurred. The default NIO2 behavior is used: the completion handler will be called as soon as some data has been read, even if the read has completed inline.- Type Parameters:
- A- The attachment type
- Parameters:
- timeout- timeout duration for the read
- unit- units for the timeout duration
- attachment- an object to attach to the I/O operation that will be used when calling the completion handler
- handler- to call when the IO is complete
- dsts- buffers
- Returns:
- the completion state (done, done inline, or still pending)
 
 - 
readpublic final <A> SocketWrapperBase.CompletionState read(SocketWrapperBase.BlockingMode block, long timeout, java.util.concurrent.TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler, java.nio.ByteBuffer... dsts) Scatter read. The completion handler will be called once some data has been read or an error occurred. If a CompletionCheck object has been provided, the completion handler will only be called if the callHandler method returned true. If no CompletionCheck object has been provided, the default NIO2 behavior is used: the completion handler will be called as soon as some data has been read, even if the read has completed inline.- Type Parameters:
- A- The attachment type
- Parameters:
- block- is the blocking mode that will be used for this operation
- timeout- timeout duration for the read
- unit- units for the timeout duration
- attachment- an object to attach to the I/O operation that will be used when calling the completion handler
- check- for the IO operation completion
- handler- to call when the IO is complete
- dsts- buffers
- Returns:
- the completion state (done, done inline, or still pending)
 
 - 
readpublic final <A> SocketWrapperBase.CompletionState read(java.nio.ByteBuffer[] dsts, int offset, int length, SocketWrapperBase.BlockingMode block, long timeout, java.util.concurrent.TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler) Scatter read. The completion handler will be called once some data has been read or an error occurred. If a CompletionCheck object has been provided, the completion handler will only be called if the callHandler method returned true. If no CompletionCheck object has been provided, the default NIO2 behavior is used: the completion handler will be called as soon as some data has been read, even if the read has completed inline.- Type Parameters:
- A- The attachment type
- Parameters:
- dsts- buffers
- offset- in the buffer array
- length- in the buffer array
- block- is the blocking mode that will be used for this operation
- timeout- timeout duration for the read
- unit- units for the timeout duration
- attachment- an object to attach to the I/O operation that will be used when calling the completion handler
- check- for the IO operation completion
- handler- to call when the IO is complete
- Returns:
- the completion state (done, done inline, or still pending)
 
 - 
writepublic final <A> SocketWrapperBase.CompletionState write(long timeout, java.util.concurrent.TimeUnit unit, A attachment, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler, java.nio.ByteBuffer... srcs) Gather write. The completion handler will be called once some data has been written or an error occurred. The default NIO2 behavior is used: the completion handler will be called, even if the write is incomplete and data remains in the buffers, or if the write completed inline.- Type Parameters:
- A- The attachment type
- Parameters:
- timeout- timeout duration for the write
- unit- units for the timeout duration
- attachment- an object to attach to the I/O operation that will be used when calling the completion handler
- handler- to call when the IO is complete
- srcs- buffers
- Returns:
- the completion state (done, done inline, or still pending)
 
 - 
writepublic final <A> SocketWrapperBase.CompletionState write(SocketWrapperBase.BlockingMode block, long timeout, java.util.concurrent.TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler, java.nio.ByteBuffer... srcs) Gather write. The completion handler will be called once some data has been written or an error occurred. If a CompletionCheck object has been provided, the completion handler will only be called if the callHandler method returned true. If no CompletionCheck object has been provided, the default NIO2 behavior is used: the completion handler will be called, even if the write is incomplete and data remains in the buffers, or if the write completed inline.- Type Parameters:
- A- The attachment type
- Parameters:
- block- is the blocking mode that will be used for this operation
- timeout- timeout duration for the write
- unit- units for the timeout duration
- attachment- an object to attach to the I/O operation that will be used when calling the completion handler
- check- for the IO operation completion
- handler- to call when the IO is complete
- srcs- buffers
- Returns:
- the completion state (done, done inline, or still pending)
 
 - 
writepublic final <A> SocketWrapperBase.CompletionState write(java.nio.ByteBuffer[] srcs, int offset, int length, SocketWrapperBase.BlockingMode block, long timeout, java.util.concurrent.TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler) Gather write. The completion handler will be called once some data has been written or an error occurred. If a CompletionCheck object has been provided, the completion handler will only be called if the callHandler method returned true. If no CompletionCheck object has been provided, the default NIO2 behavior is used: the completion handler will be called, even if the write is incomplete and data remains in the buffers, or if the write completed inline.- Type Parameters:
- A- The attachment type
- Parameters:
- srcs- buffers
- offset- in the buffer array
- length- in the buffer array
- block- is the blocking mode that will be used for this operation
- timeout- timeout duration for the write
- unit- units for the timeout duration
- attachment- an object to attach to the I/O operation that will be used when calling the completion handler
- check- for the IO operation completion
- handler- to call when the IO is complete
- Returns:
- the completion state (done, done inline, or still pending)
 
 - 
vectoredOperationprotected final <A> SocketWrapperBase.CompletionState vectoredOperation(boolean read, java.nio.ByteBuffer[] buffers, int offset, int length, SocketWrapperBase.BlockingMode block, long timeout, java.util.concurrent.TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler) Vectored operation. The completion handler will be called once the operation is complete or an error occurred. If a CompletionCheck object has been provided, the completion handler will only be called if the callHandler method returned true. If no CompletionCheck object has been provided, the default NIO2 behavior is used: the completion handler will be called, even if the operation is incomplete, or if the operation completed inline.- Type Parameters:
- A- The attachment type
- Parameters:
- read- true if the operation is a read, false if it is a write
- buffers- buffers
- offset- in the buffer array
- length- in the buffer array
- block- is the blocking mode that will be used for this operation
- timeout- timeout duration for the write
- unit- units for the timeout duration
- attachment- an object to attach to the I/O operation that will be used when calling the completion handler
- check- for the IO operation completion
- handler- to call when the IO is complete
- Returns:
- the completion state (done, done inline, or still pending)
 
 - 
newOperationStateprotected abstract <A> SocketWrapperBase.OperationState<A> newOperationState(boolean read, java.nio.ByteBuffer[] buffers, int offset, int length, SocketWrapperBase.BlockingMode block, long timeout, java.util.concurrent.TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, java.nio.channels.CompletionHandler<java.lang.Long,? super A> handler, java.util.concurrent.Semaphore semaphore, SocketWrapperBase.VectoredIOCompletionHandler<A> completion) 
 - 
transferprotected static int transfer(byte[] from, int offset, int length, java.nio.ByteBuffer to)
 - 
transferprotected static int transfer(java.nio.ByteBuffer from, java.nio.ByteBuffer to)
 - 
buffersArrayHasRemainingprotected static boolean buffersArrayHasRemaining(java.nio.ByteBuffer[] buffers, int offset, int length)
 
- 
 
-