Top Description Inners Fields Constructors Methods
io.netty.channel.nio

public abstract Class AbstractNioByteChannel

extends AbstractNioChannel
Class Inheritance
Known Direct Subclasses
io.netty.channel.socket.nio.NioSocketChannel
Imports
io.netty.buffer.ByteBuf, .ByteBufAllocator, io.netty.channel.Channel, .ChannelConfig, .ChannelFuture, .ChannelMetadata, .ChannelOutboundBuffer, .ChannelPipeline, .FileRegion, .RecvByteBufAllocator, io.netty.channel.internal.ChannelUtils, io.netty.channel.socket.ChannelInputShutdownEvent, .ChannelInputShutdownReadComplete, .SocketChannelConfig, io.netty.util.internal.StringUtil, java.io.IOException, java.nio.channels.SelectableChannel, .SelectionKey

AbstractNioChannel base class for Channels that operate on bytes.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class

Field Summary

Modifier and TypeField and Description
private static final String
private final Runnable
private boolean
private static final ChannelMetadata
Inherited from io.netty.channel.nio.AbstractNioChannel:
readInterestOpreadPendingselectionKey

Constructor Summary

AccessConstructor and Description
protected
AbstractNioByteChannel(Channel
the parent Channel by which this instance was created. May be null
parent
,
SelectableChannel
the underlying SelectableChannel on which it operates
ch
)

Create a new instance

Method Summary

Modifier and TypeMethod and Description
protected final void
protected abstract int
doReadBytes(ByteBuf buf)

Read bytes into the given ByteBuf and return the amount.

protected void
doWrite(ChannelOutboundBuffer in)

Implements abstract io.netty.channel.AbstractChannel.doWrite.

Flush the content of the given buffer to the remote peer.
protected final int

Returns:

The value that should be decremented from the write quantum which starts at ChannelConfig#getWriteSpinCount(). The typical use cases are as follows:
  • 0 - if no write was attempted. This is appropriate if an empty ByteBuf (or other empty content) is encountered
  • 1 - if a single call to write data was made to the OS
  • ChannelUtils#WRITE_STATUS_SNDBUF_FULL - if an attempt to write data was made to the OS, but no data was accepted
doWrite0
(ChannelOutboundBuffer
the collection which contains objects to write.
in
)

Write objects to the OS.

protected abstract int

Returns:

amount the amount of written bytes
doWriteBytes
(ByteBuf
the ByteBuf from which the bytes should be written
buf
)

Write bytes form the given ByteBuf to the underlying java.nio.channels.Channel.

protected abstract long

Returns:

amount the amount of written bytes
doWriteFileRegion
(FileRegion
the FileRegion from which the bytes should be written
region
)

Write a FileRegion

private int
protected final Object
filterOutboundMessage(Object msg)

Overrides io.netty.channel.AbstractChannel.filterOutboundMessage.

Invoked when a new message is added to a ChannelOutboundBuffer of this AbstractChannel, so that the Channel implementation converts the message to another.
protected final void
incompleteWrite(boolean setOpWrite)

private static boolean
protected boolean
public ChannelMetadata
metadata()

Implements io.netty.channel.Channel.metadata.

Return the ChannelMetadata of the Channel which describe the nature of the Channel.
protected AbstractNioChannel.AbstractNioUnsafe
newUnsafe()

Implements abstract io.netty.channel.AbstractChannel.newUnsafe.

Create a new AbstractUnsafe instance which will be used for the life-time of the Channel
protected final void
pack-priv final boolean
protected abstract ChannelFuture
shutdownInput()

Shutdown the input side of the channel.

Inherited from io.netty.channel.nio.AbstractNioChannel:
clearReadPendingdoBeginReaddoClosedoConnectdoDeregisterdoFinishConnectdoRegistereventLoopisCompatibleisOpenisReadPendingjavaChannelnewDirectBuffernewDirectBufferselectionKeysetReadPendingunsafe

Field Detail

EXPECTED_TYPESback to summary
private static final String EXPECTED_TYPES
flushTaskback to summary
private final Runnable flushTask
inputClosedSeenErrorOnReadback to summary
private boolean inputClosedSeenErrorOnRead
METADATAback to summary
private static final ChannelMetadata METADATA

Constructor Detail

AbstractNioByteChannelback to summary
protected AbstractNioByteChannel(Channel parent, SelectableChannel ch)

Create a new instance

Parameters
parent:Channel

the parent Channel by which this instance was created. May be null

ch:SelectableChannel

the underlying SelectableChannel on which it operates

Method Detail

clearOpWriteback to summary
protected final void clearOpWrite()
doReadBytesback to summary
protected abstract int doReadBytes(ByteBuf buf) throws Exception

Read bytes into the given ByteBuf and return the amount.

doWriteback to summary
protected void doWrite(ChannelOutboundBuffer in) throws Exception

Implements abstract io.netty.channel.AbstractChannel.doWrite.

Doc from io.netty.channel.AbstractChannel.doWrite.

Flush the content of the given buffer to the remote peer.

Annotations
@Override
doWrite0back to summary
protected final int doWrite0(ChannelOutboundBuffer in) throws Exception

Write objects to the OS.

Parameters
in:ChannelOutboundBuffer

the collection which contains objects to write.

Returns:int

The value that should be decremented from the write quantum which starts at ChannelConfig#getWriteSpinCount(). The typical use cases are as follows:

  • 0 - if no write was attempted. This is appropriate if an empty ByteBuf (or other empty content) is encountered
  • 1 - if a single call to write data was made to the OS
  • ChannelUtils#WRITE_STATUS_SNDBUF_FULL - if an attempt to write data was made to the OS, but no data was accepted
Exceptions
Exception:
if an I/O exception occurs during write.
doWriteBytesback to summary
protected abstract int doWriteBytes(ByteBuf buf) throws Exception

Write bytes form the given ByteBuf to the underlying java.nio.channels.Channel.

Parameters
buf:ByteBuf

the ByteBuf from which the bytes should be written

Returns:int

amount the amount of written bytes

doWriteFileRegionback to summary
protected abstract long doWriteFileRegion(FileRegion region) throws Exception

Write a FileRegion

Parameters
region:FileRegion

the FileRegion from which the bytes should be written

Returns:long

amount the amount of written bytes

doWriteInternalback to summary
private int doWriteInternal(ChannelOutboundBuffer in, Object msg) throws Exception
filterOutboundMessageback to summary
protected final Object filterOutboundMessage(Object msg)

Overrides io.netty.channel.AbstractChannel.filterOutboundMessage.

Doc from io.netty.channel.AbstractChannel.filterOutboundMessage.

Invoked when a new message is added to a ChannelOutboundBuffer of this AbstractChannel, so that the Channel implementation converts the message to another. (e.g. heap buffer -> direct buffer)

Annotations
@Override
incompleteWriteback to summary
protected final void incompleteWrite(boolean setOpWrite)
isAllowHalfClosureback to summary
private static boolean isAllowHalfClosure(ChannelConfig config)
isInputShutdown0back to summary
protected boolean isInputShutdown0()
metadataback to summary
public ChannelMetadata metadata()

Implements io.netty.channel.Channel.metadata.

Doc from io.netty.channel.Channel.metadata.

Return the ChannelMetadata of the Channel which describe the nature of the Channel.

Annotations
@Override
newUnsafeback to summary
protected AbstractNioChannel.AbstractNioUnsafe newUnsafe()

Implements abstract io.netty.channel.AbstractChannel.newUnsafe.

Doc from io.netty.channel.AbstractChannel.newUnsafe.

Create a new AbstractUnsafe instance which will be used for the life-time of the Channel

Annotations
@Override
setOpWriteback to summary
protected final void setOpWrite()
shouldBreakReadReadyback to summary
pack-priv final boolean shouldBreakReadReady(ChannelConfig config)
shutdownInputback to summary
protected abstract ChannelFuture shutdownInput()

Shutdown the input side of the channel.

io.netty.channel.nio back to summary

protected Class AbstractNioByteChannel.NioByteUnsafe

extends AbstractNioUnsafe
Class Inheritance
Known Direct Subclasses
io.netty.channel.socket.nio.NioSocketChannel.NioSocketChannelUnsafe

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
private void
private void
handleReadException(ChannelPipeline pipeline, ByteBuf byteBuf, Throwable cause, boolean close, RecvByteBufAllocator.Handle allocHandle)

Deprecated as a consequence of RecvByteBufAllocator.Handle being deprecated.
public final void
Inherited from io.netty.channel.nio.AbstractNioChannel.AbstractNioUnsafe:
chconnectfinishConnectflush0forceFlushremoveReadOp

Constructor Detail

NioByteUnsafeback to summary
protected NioByteUnsafe()

Method Detail

closeOnReadback to summary
private void closeOnRead(ChannelPipeline pipeline)
handleReadExceptionback to summary
private void handleReadException(ChannelPipeline pipeline, ByteBuf byteBuf, Throwable cause, boolean close, RecvByteBufAllocator.Handle allocHandle)

Deprecated

as a consequence of RecvByteBufAllocator.Handle being deprecated. See corresponding docs for further information.

readback to summary
public final void read()

Implements io.netty.channel.nio.AbstractNioChannel.NioUnsafe.read.

Doc from io.netty.channel.nio.AbstractNioChannel.NioUnsafe.read.

Read from underlying SelectableChannel

Annotations
@Override