public static class Nio2Endpoint.Nio2SocketWrapper extends SocketWrapperBase<Nio2Channel>
SocketWrapperBase.CompletionCheck, SocketWrapperBase.CompletionHandlerCall, SocketWrapperBase.CompletionState
bufferedWrites, bufferedWriteSize, COMPLETE_WRITE, 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() |
void |
close() |
SendfileDataBase |
createSendfileData(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 |
doWriteInternal(boolean block)
Write the contents of the socketWriteBuffer to the socket.
|
protected void |
flushBlocking() |
protected boolean |
flushNonBlocking() |
IOException |
getError() |
Nio2Endpoint.SendfileData |
getSendfileData() |
SSLSupport |
getSslSupport(String clientCertProvider) |
boolean |
hasAsyncIO()
Allows using NIO2 style read/write only for connectors that can
efficiently support it.
|
boolean |
hasDataToWrite() |
boolean |
isReadPending() |
boolean |
isReadyForRead() |
boolean |
isWritePending() |
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) |
<A> SocketWrapperBase.CompletionState |
read(ByteBuffer[] dsts,
int offset,
int length,
boolean block,
long timeout,
TimeUnit unit,
A attachment,
SocketWrapperBase.CompletionCheck check,
CompletionHandler<Long,? super A> handler)
Scatter read.
|
void |
registerReadInterest() |
void |
registerWriteInterest() |
void |
setError(IOException error) |
void |
setSendfileData(Nio2Endpoint.SendfileData sf) |
<A> SocketWrapperBase.CompletionState |
write(ByteBuffer[] srcs,
int offset,
int length,
boolean block,
long timeout,
TimeUnit unit,
A attachment,
SocketWrapperBase.CompletionCheck check,
CompletionHandler<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.
|
addToBuffers, canWrite, decrementKeepAlive, doWrite, executeNonBlockingDispatches, flush, getBlockingStatus, getBlockingStatusReadLock, getBlockingStatusWriteLock, getEndpoint, getLocalAddr, getLocalName, getLocalPort, getNegotiatedProtocol, getReadTimeout, getRemoteAddr, getRemoteHost, getRemotePort, getSocket, getSocketBufferHandler, getWriteThreadLock, getWriteTimeout, isKeptAlive, isReadyForWrite, isSecure, isUpgraded, processSocket, read, setBlockingStatus, setKeepAliveLeft, setKeptAlive, setNegotiatedProtocol, setReadTimeout, setSecure, setUpgraded, setWriteTimeout, toString, transfer, transfer, unRead, write, write, writeBlocking
public Nio2SocketWrapper(Nio2Channel channel, Nio2Endpoint endpoint)
public void setSendfileData(Nio2Endpoint.SendfileData sf)
public Nio2Endpoint.SendfileData getSendfileData()
public IOException getError()
public void setError(IOException error)
public boolean isReadyForRead() throws IOException
isReadyForRead
in class SocketWrapperBase<Nio2Channel>
IOException
public int read(boolean block, byte[] b, int off, int len) throws IOException
read
in class SocketWrapperBase<Nio2Channel>
IOException
public void close() throws IOException
close
in class SocketWrapperBase<Nio2Channel>
IOException
public boolean hasAsyncIO()
SocketWrapperBase
hasAsyncIO
in class SocketWrapperBase<Nio2Channel>
public <A> SocketWrapperBase.CompletionState read(ByteBuffer[] dsts, int offset, int length, boolean block, long timeout, TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, CompletionHandler<Long,? super A> handler)
SocketWrapperBase
read
in class SocketWrapperBase<Nio2Channel>
dsts
- buffersoffset
- in the buffer arraylength
- in the buffer arrayblock
- true to block until any pending read is done, if the
timeout occurs and a read is still pending, a
ReadPendingException will be thrown; false to
not block but any pending read operation will cause
a ReadPendingExceptioncheck
- for the IO operation completionhandler
- to call when the IO is completepublic boolean isWritePending()
isWritePending
in class SocketWrapperBase<Nio2Channel>
public <A> SocketWrapperBase.CompletionState write(ByteBuffer[] srcs, int offset, int length, boolean block, long timeout, TimeUnit unit, A attachment, SocketWrapperBase.CompletionCheck check, CompletionHandler<Long,? super A> handler)
SocketWrapperBase
write
in class SocketWrapperBase<Nio2Channel>
srcs
- buffersoffset
- in the buffer arraylength
- in the buffer arrayblock
- true to block until any pending write is done, if the
timeout occurs and a write is still pending, a
WritePendingException will be thrown; false to
not block but any pending write operation will cause
a WritePendingExceptioncheck
- for the IO operation completionhandler
- to call when the IO is completeprotected void writeNonBlocking(byte[] buf, int off, int len) throws 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 writtenIOException
- If an IO error occurs during the writeprotected void doWriteInternal(boolean block) throws IOException
SocketWrapperBase
doWriteInternal
in class SocketWrapperBase<Nio2Channel>
block
- Ignored since this method is only called in the
blocking caseIOException
- If an I/O error such as a timeout occurs during the
writeprotected void flushBlocking() throws IOException
flushBlocking
in class SocketWrapperBase<Nio2Channel>
IOException
protected boolean flushNonBlocking() throws IOException
flushNonBlocking
in class SocketWrapperBase<Nio2Channel>
IOException
public boolean hasDataToWrite()
hasDataToWrite
in class SocketWrapperBase<Nio2Channel>
public boolean isReadPending()
isReadPending
in class SocketWrapperBase<Nio2Channel>
public void registerReadInterest()
registerReadInterest
in class SocketWrapperBase<Nio2Channel>
public void registerWriteInterest()
registerWriteInterest
in class SocketWrapperBase<Nio2Channel>
public void awaitBytes()
public SendfileDataBase createSendfileData(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(String clientCertProvider)
getSslSupport
in class SocketWrapperBase<Nio2Channel>
clientCertProvider
- Ignored for this implementationpublic void doClientAuth(SSLSupport sslSupport)
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
authenticationCopyright © 2000-2015 Apache Software Foundation. All Rights Reserved.