public class NioChannel
extends java.lang.Object
implements java.nio.channels.ByteChannel, java.nio.channels.ScatteringByteChannel, java.nio.channels.GatheringByteChannel
Modifier and Type | Field and Description |
---|---|
protected SocketBufferHandler |
bufHandler |
protected static java.nio.ByteBuffer |
emptyBuf |
protected java.nio.channels.SocketChannel |
sc |
protected static StringManager |
sm |
protected NioEndpoint.NioSocketWrapper |
socketWrapper |
Constructor and Description |
---|
NioChannel(SocketBufferHandler bufHandler) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkInterruptStatus()
This method should be used to check the interrupt status before
attempting a write.
|
void |
close()
Closes this channel.
|
void |
close(boolean force)
Close the connection.
|
boolean |
flush(boolean block,
java.nio.channels.Selector s,
long timeout)
Returns true if the network buffer has been flushed out and is empty.
|
boolean |
flushOutbound()
Return true if the buffer wrote data.
|
void |
free()
Free the channel memory
|
protected ApplicationBufferHandler |
getAppReadBufHandler() |
SocketBufferHandler |
getBufHandler() |
java.nio.channels.SocketChannel |
getIOChannel() |
int |
getOutboundRemaining() |
int |
handshake(boolean read,
boolean write)
Performs SSL handshake hence is a no-op for the non-secure
implementation.
|
boolean |
isClosing() |
boolean |
isHandshakeComplete() |
boolean |
isOpen()
Tells whether or not this channel is open.
|
int |
read(java.nio.ByteBuffer dst)
Reads a sequence of bytes from this channel into the given buffer.
|
long |
read(java.nio.ByteBuffer[] dsts) |
long |
read(java.nio.ByteBuffer[] dsts,
int offset,
int length) |
void |
reset(java.nio.channels.SocketChannel channel,
NioEndpoint.NioSocketWrapper socketWrapper)
Reset the channel
|
void |
setAppReadBufHandler(ApplicationBufferHandler handler) |
java.lang.String |
toString() |
int |
write(java.nio.ByteBuffer src)
Writes a sequence of bytes to this channel from the given buffer.
|
long |
write(java.nio.ByteBuffer[] srcs) |
long |
write(java.nio.ByteBuffer[] srcs,
int offset,
int length) |
protected static final StringManager sm
protected static final java.nio.ByteBuffer emptyBuf
protected final SocketBufferHandler bufHandler
protected java.nio.channels.SocketChannel sc
protected NioEndpoint.NioSocketWrapper socketWrapper
public NioChannel(SocketBufferHandler bufHandler)
public void reset(java.nio.channels.SocketChannel channel, NioEndpoint.NioSocketWrapper socketWrapper) throws java.io.IOException
channel
- the socket channelsocketWrapper
- the socket wrapperjava.io.IOException
- If a problem was encountered resetting the channelpublic void free()
public boolean flush(boolean block, java.nio.channels.Selector s, long timeout) throws java.io.IOException
block
- Unused. May be used when overriddens
- Unused. May be used when overriddentimeout
- Unused. May be used when overriddentrue
since there is no network buffer
in the regular channeljava.io.IOException
- Never for non-secure channelpublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface java.nio.channels.Channel
java.io.IOException
- If an I/O error occurspublic void close(boolean force) throws java.io.IOException
force
- Should the underlying socket be forcibly closed?java.io.IOException
- If closing the secure channel fails.public boolean isOpen()
isOpen
in interface java.nio.channels.Channel
true
if, and only if, this channel is openpublic int write(java.nio.ByteBuffer src) throws java.io.IOException
write
in interface java.nio.channels.WritableByteChannel
src
- The buffer from which bytes are to be retrievedjava.io.IOException
- If some other I/O error occurspublic long write(java.nio.ByteBuffer[] srcs) throws java.io.IOException
write
in interface java.nio.channels.GatheringByteChannel
java.io.IOException
public long write(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException
write
in interface java.nio.channels.GatheringByteChannel
java.io.IOException
public int read(java.nio.ByteBuffer dst) throws java.io.IOException
read
in interface java.nio.channels.ReadableByteChannel
dst
- The buffer into which bytes are to be transferred-1
if
the channel has reached end-of-streamjava.io.IOException
- If some other I/O error occurspublic long read(java.nio.ByteBuffer[] dsts) throws java.io.IOException
read
in interface java.nio.channels.ScatteringByteChannel
java.io.IOException
public long read(java.nio.ByteBuffer[] dsts, int offset, int length) throws java.io.IOException
read
in interface java.nio.channels.ScatteringByteChannel
java.io.IOException
public SocketBufferHandler getBufHandler()
public java.nio.channels.SocketChannel getIOChannel()
public boolean isClosing()
public boolean isHandshakeComplete()
public int handshake(boolean read, boolean write) throws java.io.IOException
read
- Unused in non-secure implementationwrite
- Unused in non-secure implementationjava.io.IOException
- Never for non-secure channelpublic java.lang.String toString()
toString
in class java.lang.Object
public int getOutboundRemaining()
public boolean flushOutbound() throws java.io.IOException
false
for non-secure channeljava.io.IOException
- Never for non-secure channelprotected void checkInterruptStatus() throws java.io.IOException
java.io.IOException
- If the current thread was interruptedpublic void setAppReadBufHandler(ApplicationBufferHandler handler)
protected ApplicationBufferHandler getAppReadBufHandler()
Copyright © 2000-2023 Apache Software Foundation. All Rights Reserved.