Package org.java_websocket
Class SSLSocketChannel2
java.lang.Object
org.java_websocket.SSLSocketChannel2
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- ByteChannel,- Channel,- ReadableByteChannel,- WritableByteChannel,- ISSLChannel,- WrappedByteChannel
public class SSLSocketChannel2
extends Object
implements ByteChannel, WrappedByteChannel, ISSLChannel
Implements the relevant portions of the SocketChannel interface with the SSLEngine wrapper.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected intShould be used to count the buffer allocations.protected static ByteBufferThis object is used to feed theSSLEngine's wrap and unwrap methods during the handshake phase.protected ExecutorServiceprotected ByteBufferencrypted data incomingprotected ByteBufferraw payload incomingprotected ByteBufferencrypted data outgoingprotected SSLEngineResultprotected SelectionKeyused to set interestOP SelectionKey.OP_WRITE for the underlying channelprotected SocketChannelthe underlying channelprotected SSLEngineprotected SSLEngineResult
- 
Constructor SummaryConstructorsConstructorDescriptionSSLSocketChannel2(SocketChannel channel, SSLEngine sslEngine, ExecutorService exec, SelectionKey key) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()configureBlocking(boolean b) booleanconnect(SocketAddress remote) protected voidprotected voidcreateBuffers(SSLSession session) booleanGet the ssl engine used for the de- and encryption of the communication.booleanThis function returns the blocking state of the channelbooleanbooleanbooleanreturns whether readMore should be called to fetch data which has been decoded but not yet been returned.booleanreturns whether writeMore should be called write additional data.booleanisOpen()intread(ByteBuffer dst) Blocks when in blocking mode until at least one byte has been decoded.
 When not in blocking mode 0 may be returned.intreadMore(ByteBuffer dst) This function does not read data from the underlying channel at all.socket()intwrite(ByteBuffer src) voidGets called whenWrappedByteChannel.isNeedWrite()()} requires a additional rite
- 
Field Details- 
emptybufferThis object is used to feed theSSLEngine's wrap and unwrap methods during the handshake phase.
- 
exec
- 
tasks
- 
inDataraw payload incoming
- 
outCryptencrypted data outgoing
- 
inCryptencrypted data incoming
- 
socketChannelthe underlying channel
- 
selectionKeyused to set interestOP SelectionKey.OP_WRITE for the underlying channel
- 
sslEngine
- 
readEngineResult
- 
writeEngineResult
- 
bufferallocationsprotected int bufferallocationsShould be used to count the buffer allocations. But because of #190 where HandshakeStatus.FINISHED is not properly returned by nio wrap/unwrap this variable is used to check whethercreateBuffers(SSLSession)needs to be called.
 
- 
- 
Constructor Details- 
SSLSocketChannel2public SSLSocketChannel2(SocketChannel channel, SSLEngine sslEngine, ExecutorService exec, SelectionKey key) throws IOException - Throws:
- IOException
 
 
- 
- 
Method Details- 
consumeDelegatedTasksprotected void consumeDelegatedTasks()
- 
createBuffers
- 
write- Specified by:
- writein interface- WritableByteChannel
- Throws:
- IOException
 
- 
readBlocks when in blocking mode until at least one byte has been decoded.
 When not in blocking mode 0 may be returned.- Specified by:
- readin interface- ReadableByteChannel
- Returns:
- the number of bytes read.
- Throws:
- IOException
 
- 
isConnectedpublic boolean isConnected()
- 
close- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Channel
- Specified by:
- closein interface- Closeable
- Throws:
- IOException
 
- 
configureBlocking- Throws:
- IOException
 
- 
connect- Throws:
- IOException
 
- 
finishConnect- Throws:
- IOException
 
- 
socket
- 
isInboundDonepublic boolean isInboundDone()
- 
isOpenpublic boolean isOpen()
- 
isNeedWritepublic boolean isNeedWrite()Description copied from interface:WrappedByteChannelreturns whether writeMore should be called write additional data.- Specified by:
- isNeedWritein interface- WrappedByteChannel
- Returns:
- is a additional write needed
 
- 
writeMoreDescription copied from interface:WrappedByteChannelGets called whenWrappedByteChannel.isNeedWrite()()} requires a additional rite- Specified by:
- writeMorein interface- WrappedByteChannel
- Throws:
- IOException- may be thrown due to an error while writing
 
- 
isNeedReadpublic boolean isNeedRead()Description copied from interface:WrappedByteChannelreturns whether readMore should be called to fetch data which has been decoded but not yet been returned.- Specified by:
- isNeedReadin interface- WrappedByteChannel
- Returns:
- is a additional read needed
- See Also:
 
- 
readMoreDescription copied from interface:WrappedByteChannelThis function does not read data from the underlying channel at all. It is just a way to fetch data which has already be received or decoded but was but was not yet returned to the user. This could be the case when the decoded data did not fit into the buffer the user passed toReadableByteChannel.read(ByteBuffer).- Specified by:
- readMorein interface- WrappedByteChannel
- Parameters:
- dst- the destiny of the read
- Returns:
- the amount of remaining data
- Throws:
- SSLException
 
- 
isBlockingpublic boolean isBlocking()Description copied from interface:WrappedByteChannelThis function returns the blocking state of the channel- Specified by:
- isBlockingin interface- WrappedByteChannel
- Returns:
- is the channel blocking
 
- 
getSSLEngineDescription copied from interface:ISSLChannelGet the ssl engine used for the de- and encryption of the communication.- Specified by:
- getSSLEnginein interface- ISSLChannel
- Returns:
- the ssl engine of this channel
 
 
-