public static class Nio2Endpoint.Nio2SocketWrapper extends SocketWrapperBase<Nio2Channel>
SocketWrapperBase.BlockingMode, SocketWrapperBase.CompletionCheck, SocketWrapperBase.CompletionHandlerCall, SocketWrapperBase.CompletionState
bufferedWrites, bufferedWriteSize, COMPLETE_WRITE, COMPLETE_WRITE_WITH_COMPLETION, localAddr, localName, localPort, READ_DATA, remoteAddr, remoteHost, remotePort, sm, socketBufferHandler
Constructor and Description |
---|
Nio2SocketWrapper(Nio2Channel channel,
Nio2Endpoint endpoint) |
Modifier and Type | Method and Description |
---|---|
void |
awaitBytes() |
boolean |
awaitReadComplete(long timeout,
java.util.concurrent.TimeUnit unit)
If an asynchronous read operation is pending, this method will block
until the operation completes, or the specified amount of time
has passed.
|
boolean |
awaitWriteComplete(long timeout,
java.util.concurrent.TimeUnit unit)
If an asynchronous write operation is pending, this method will block
until the operation completes, or the specified amount of time
has passed.
|
void |
close() |
SendfileDataBase |
createSendfileData(java.lang.String filename,
long pos,
long length) |
void |
doClientAuth(SSLSupport sslSupport)
Require the client to perform CLIENT-CERT authentication if it hasn't
already done so.
|
protected void |
doWrite(boolean block,
java.nio.ByteBuffer from)
Write the contents of the ByteBuffer to the socket.
|
protected void |
flushBlocking() |
protected boolean |
flushNonBlocking() |
Nio2Endpoint.SendfileData |
getSendfileData() |
SSLSupport |
getSslSupport(java.lang.String clientCertProvider) |
boolean |
hasAsyncIO()
Allows using NIO2 style read/write only for connectors that can
efficiently support it.
|
boolean |
hasDataToWrite() |
boolean |
isClosed() |
boolean |
isReadPending()
Allows checking if an asynchronous read operation is currently pending.
|
boolean |
isReadyForRead() |
boolean |
isWritePending()
Allows checking if an asynchronous write operation is currently pending.
|
protected void |
populateLocalAddr() |
protected void |
populateLocalName() |
protected void |
populateLocalPort() |
protected void |
populateRemoteAddr() |
protected void |
populateRemoteHost() |
protected void |
populateRemotePort() |
SendfileState |
processSendfile(SendfileDataBase sendfileData)
Starts the sendfile process.
|
int |
read(boolean block,
byte[] b,
int off,
int len) |
int |
read(boolean block,
java.nio.ByteBuffer to) |
<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.
|
void |
registerReadInterest() |
void |
registerWriteInterest() |
void |
setAppReadBufHandler(ApplicationBufferHandler handler) |
void |
setSendfileData(Nio2Endpoint.SendfileData sf) |
<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.
|
protected void |
writeNonBlocking(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 void |
writeNonBlocking(java.nio.ByteBuffer from)
Writes the data to the socket (writing that data to the socket 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.
|
addToBuffers, addToBuffers, canWrite, checkError, decrementKeepAlive, doWrite, execute, flush, getBlockingStatus, getBlockingStatusReadLock, getBlockingStatusWriteLock, getEndpoint, getError, getLocalAddr, getLocalName, getLocalPort, getNegotiatedProtocol, getReadTimeout, getRemoteAddr, getRemoteHost, getRemotePort, getSocket, getSocketBufferHandler, getWriteTimeout, isReadyForWrite, isSecure, isUpgraded, populateReadBuffer, populateReadBuffer, processSocket, read, setBlockingStatus, setError, setKeepAliveLeft, setNegotiatedProtocol, setReadTimeout, setSecure, setUpgraded, setWriteTimeout, toString, transfer, transfer, unRead, write, write, write, writeBlocking, writeBlocking, writeByteBufferBlocking, writeByteBufferNonBlocking
public Nio2SocketWrapper(Nio2Channel channel, Nio2Endpoint endpoint)
public void setSendfileData(Nio2Endpoint.SendfileData sf)
public Nio2Endpoint.SendfileData getSendfileData()
public boolean isReadyForRead() throws java.io.IOException
isReadyForRead
in class SocketWrapperBase<Nio2Channel>
java.io.IOException
public int read(boolean block, byte[] b, int off, int len) throws java.io.IOException
read
in class SocketWrapperBase<Nio2Channel>
java.io.IOException
public int read(boolean block, java.nio.ByteBuffer to) throws java.io.IOException
read
in class SocketWrapperBase<Nio2Channel>
java.io.IOException
public void close() throws java.io.IOException
close
in class SocketWrapperBase<Nio2Channel>
java.io.IOException
public boolean isClosed()
isClosed
in class SocketWrapperBase<Nio2Channel>
public boolean isWritePending()
SocketWrapperBase
isWritePending
in class SocketWrapperBase<Nio2Channel>
true
if the endpoint supports asynchronous IO and
a write operation is being processed asynchronouslypublic boolean hasAsyncIO()
SocketWrapperBase
hasAsyncIO
in class SocketWrapperBase<Nio2Channel>
false
public <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)
SocketWrapperBase
read
in class SocketWrapperBase<Nio2Channel>
A
- The attachment typedsts
- buffersoffset
- in the buffer arraylength
- in the buffer arrayblock
- is the blocking mode that will be used for this operationtimeout
- timeout duration for the readunit
- units for the timeout durationattachment
- an object to attach to the I/O operation that will be
used when calling the completion handlercheck
- for the IO operation completionhandler
- to call when the IO is completepublic <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)
SocketWrapperBase
write
in class SocketWrapperBase<Nio2Channel>
A
- The attachment typesrcs
- buffersoffset
- in the buffer arraylength
- in the buffer arrayblock
- is the blocking mode that will be used for this operationtimeout
- timeout duration for the writeunit
- units for the timeout durationattachment
- an object to attach to the I/O operation that will be
used when calling the completion handlercheck
- for the IO operation completionhandler
- to call when the IO is completeprotected void writeNonBlocking(byte[] buf, int off, int len) throws java.io.IOException
Overridden for NIO2 to enable a gathering write to be used to write all of the remaining data in a single additional write should a non-blocking write leave data in the buffer.
writeNonBlocking
in class SocketWrapperBase<Nio2Channel>
buf
- The byte array containing the data to be writtenoff
- The offset within the byte array of the data to be writtenlen
- The length of the data to be writtenjava.io.IOException
- If an IO error occurs during the writeprotected void writeNonBlocking(java.nio.ByteBuffer from) throws java.io.IOException
Overridden for NIO2 to enable a gathering write to be used to write all of the remaining data in a single additional write should a non-blocking write leave data in the buffer.
writeNonBlocking
in class SocketWrapperBase<Nio2Channel>
from
- The ByteBuffer containing the data to be writtenjava.io.IOException
- If an IO error occurs during the writeprotected void doWrite(boolean block, java.nio.ByteBuffer from) throws java.io.IOException
SocketWrapperBase
doWrite
in class SocketWrapperBase<Nio2Channel>
block
- Ignored since this method is only called in the
blocking casefrom
- the ByteBuffer containing the data to be writtenjava.io.IOException
- If an I/O error such as a timeout occurs during the
writeprotected void flushBlocking() throws java.io.IOException
flushBlocking
in class SocketWrapperBase<Nio2Channel>
java.io.IOException
protected boolean flushNonBlocking() throws java.io.IOException
flushNonBlocking
in class SocketWrapperBase<Nio2Channel>
java.io.IOException
public boolean hasDataToWrite()
hasDataToWrite
in class SocketWrapperBase<Nio2Channel>
public boolean isReadPending()
SocketWrapperBase
isReadPending
in class SocketWrapperBase<Nio2Channel>
true
if the endpoint supports asynchronous IO and
a read operation is being processed asynchronouslypublic boolean awaitReadComplete(long timeout, java.util.concurrent.TimeUnit unit)
SocketWrapperBase
awaitReadComplete
in class SocketWrapperBase<Nio2Channel>
timeout
- The maximum amount of time to waitunit
- The unit for the timeouttrue
if the read operation is complete,
false
if the operation is still pending and
the specified timeout has passedpublic boolean awaitWriteComplete(long timeout, java.util.concurrent.TimeUnit unit)
SocketWrapperBase
awaitWriteComplete
in class SocketWrapperBase<Nio2Channel>
timeout
- The maximum amount of time to waitunit
- The unit for the timeouttrue
if the read operation is complete,
false
if the operation is still pending and
the specified timeout has passedpublic void registerReadInterest()
registerReadInterest
in class SocketWrapperBase<Nio2Channel>
public void registerWriteInterest()
registerWriteInterest
in class SocketWrapperBase<Nio2Channel>
public void awaitBytes()
public SendfileDataBase createSendfileData(java.lang.String filename, long pos, long length)
createSendfileData
in class SocketWrapperBase<Nio2Channel>
public SendfileState processSendfile(SendfileDataBase sendfileData)
SocketWrapperBase
processSendfile
in class SocketWrapperBase<Nio2Channel>
sendfileData
- Data representing the file to sendprotected void populateRemoteAddr()
populateRemoteAddr
in class SocketWrapperBase<Nio2Channel>
protected void populateRemoteHost()
populateRemoteHost
in class SocketWrapperBase<Nio2Channel>
protected void populateRemotePort()
populateRemotePort
in class SocketWrapperBase<Nio2Channel>
protected void populateLocalName()
populateLocalName
in class SocketWrapperBase<Nio2Channel>
protected void populateLocalAddr()
populateLocalAddr
in class SocketWrapperBase<Nio2Channel>
protected void populateLocalPort()
populateLocalPort
in class SocketWrapperBase<Nio2Channel>
public SSLSupport getSslSupport(java.lang.String clientCertProvider)
getSslSupport
in class SocketWrapperBase<Nio2Channel>
clientCertProvider
- Ignored for this implementationpublic void doClientAuth(SSLSupport sslSupport) throws java.io.IOException
SocketWrapperBase
doClientAuth
in class SocketWrapperBase<Nio2Channel>
sslSupport
- The SSL/TLS support instance currently being used by
the connection that may need updating after the client
authenticationjava.io.IOException
- If authentication is required then there will be I/O
with the client and this exception will be thrown if
that goes wrongpublic void setAppReadBufHandler(ApplicationBufferHandler handler)
setAppReadBufHandler
in class SocketWrapperBase<Nio2Channel>
Copyright © 2000-2022 Apache Software Foundation. All Rights Reserved.