public class NioChannel extends Object implements ByteChannel, ScatteringByteChannel, GatheringByteChannel
Modifier and Type | Field and Description |
---|---|
protected SocketBufferHandler |
bufHandler |
protected static ByteBuffer |
emptyBuf |
protected NioEndpoint.Poller |
poller |
protected SocketChannel |
sc |
protected static StringManager |
sm |
protected SocketWrapperBase<NioChannel> |
socketWrapper |
Constructor and Description |
---|
NioChannel(SocketChannel channel,
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,
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() |
Object |
getAttachment() |
SocketBufferHandler |
getBufHandler() |
SocketChannel |
getIOChannel() |
int |
getOutboundRemaining() |
NioEndpoint.Poller |
getPoller() |
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(ByteBuffer dst)
Reads a sequence of bytes from this channel into the given buffer.
|
long |
read(ByteBuffer[] dsts) |
long |
read(ByteBuffer[] dsts,
int offset,
int length) |
void |
reset()
Reset the channel
|
void |
setAppReadBufHandler(ApplicationBufferHandler handler) |
void |
setIOChannel(SocketChannel IOChannel) |
void |
setPoller(NioEndpoint.Poller poller) |
String |
toString() |
int |
write(ByteBuffer src)
Writes a sequence of bytes to this channel from the given buffer.
|
long |
write(ByteBuffer[] srcs) |
long |
write(ByteBuffer[] srcs,
int offset,
int length) |
protected static final StringManager sm
protected static final ByteBuffer emptyBuf
protected SocketChannel sc
protected SocketWrapperBase<NioChannel> socketWrapper
protected final SocketBufferHandler bufHandler
protected NioEndpoint.Poller poller
public NioChannel(SocketChannel channel, SocketBufferHandler bufHandler)
public void reset() throws IOException
IOException
- If a problem was encountered resetting the channelpublic void free()
public boolean flush(boolean block, Selector s, long timeout) throws 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 channelIOException
- Never for non-secure channelpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in interface Channel
IOException
- If an I/O error occurspublic void close(boolean force) throws IOException
force
- Should the underlying socket be forcibly closed?IOException
- If closing the secure channel fails.public boolean isOpen()
public int write(ByteBuffer src) throws IOException
write
in interface WritableByteChannel
src
- The buffer from which bytes are to be retrievedIOException
- If some other I/O error occurspublic long write(ByteBuffer[] srcs) throws IOException
write
in interface GatheringByteChannel
IOException
public long write(ByteBuffer[] srcs, int offset, int length) throws IOException
write
in interface GatheringByteChannel
IOException
public int read(ByteBuffer dst) throws IOException
read
in interface ReadableByteChannel
dst
- The buffer into which bytes are to be transferred-1
if
the channel has reached end-of-streamIOException
- If some other I/O error occurspublic long read(ByteBuffer[] dsts) throws IOException
read
in interface ScatteringByteChannel
IOException
public long read(ByteBuffer[] dsts, int offset, int length) throws IOException
read
in interface ScatteringByteChannel
IOException
public Object getAttachment()
public SocketBufferHandler getBufHandler()
public NioEndpoint.Poller getPoller()
public SocketChannel getIOChannel()
public boolean isClosing()
public boolean isHandshakeComplete()
public int handshake(boolean read, boolean write) throws IOException
read
- Unused in non-secure implementationwrite
- Unused in non-secure implementationIOException
- Never for non-secure channelpublic void setPoller(NioEndpoint.Poller poller)
public void setIOChannel(SocketChannel IOChannel)
public int getOutboundRemaining()
public boolean flushOutbound() throws IOException
false
for non-secure channelIOException
- Never for non-secure channelprotected void checkInterruptStatus() throws IOException
IOException
- If the current thread was interruptedpublic void setAppReadBufHandler(ApplicationBufferHandler handler)
protected ApplicationBufferHandler getAppReadBufHandler()
Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.