Package io.netty.channel.nio
Class AbstractNioByteChannel
java.lang.Object
io.netty.util.DefaultAttributeMap
io.netty.channel.AbstractChannel
io.netty.channel.nio.AbstractNioChannel
io.netty.channel.nio.AbstractNioByteChannel
- All Implemented Interfaces:
Channel
,ChannelOutboundInvoker
,AttributeMap
,Comparable<Channel>
- Direct Known Subclasses:
NioSocketChannel
AbstractNioChannel
base class for Channel
s that operate on bytes.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class io.netty.channel.nio.AbstractNioChannel
AbstractNioChannel.AbstractNioUnsafe, AbstractNioChannel.NioUnsafe
Nested classes/interfaces inherited from class io.netty.channel.AbstractChannel
AbstractChannel.AbstractUnsafe
Nested classes/interfaces inherited from interface io.netty.channel.Channel
Channel.Unsafe
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private final Runnable
private boolean
private static final ChannelMetadata
Fields inherited from class io.netty.channel.nio.AbstractNioChannel
readInterestOp, readPending, selectionKey
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractNioByteChannel
(Channel parent, SelectableChannel ch) Create a new instance -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
protected abstract int
doReadBytes
(ByteBuf buf) Read bytes into the givenByteBuf
and return the amount.protected void
Flush the content of the given buffer to the remote peer.protected final int
Write objects to the OS.protected abstract int
doWriteBytes
(ByteBuf buf) protected abstract long
doWriteFileRegion
(FileRegion region) Write aFileRegion
private int
doWriteInternal
(ChannelOutboundBuffer in, Object msg) protected final Object
Invoked when a new message is added to aChannelOutboundBuffer
of thisAbstractChannel
, so that theChannel
implementation converts the message to another.protected final void
incompleteWrite
(boolean setOpWrite) private static boolean
isAllowHalfClosure
(ChannelConfig config) protected boolean
metadata()
protected AbstractNioChannel.AbstractNioUnsafe
Create a newAbstractChannel.AbstractUnsafe
instance which will be used for the life-time of theChannel
protected final void
(package private) final boolean
shouldBreakReadReady
(ChannelConfig config) protected abstract ChannelFuture
Shutdown the input side of the channel.Methods inherited from class io.netty.channel.nio.AbstractNioChannel
clearReadPending, doBeginRead, doClose, doConnect, doDeregister, doFinishConnect, doRegister, eventLoop, isCompatible, isOpen, isReadPending, javaChannel, newDirectBuffer, newDirectBuffer, selectionKey, setReadPending, unsafe
Methods inherited from class io.netty.channel.AbstractChannel
alloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, close, close, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, doBind, doDisconnect, doShutdownOutput, equals, flush, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, localAddress, localAddress0, maxMessagesPerWrite, newChannelPipeline, newFailedFuture, newId, newProgressivePromise, newPromise, newSucceededFuture, parent, pipeline, read, remoteAddress, remoteAddress0, toString, validateFileRegion, voidPromise, write, write, writeAndFlush, writeAndFlush
Methods inherited from class io.netty.util.DefaultAttributeMap
attr, hasAttr
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.netty.util.AttributeMap
attr, hasAttr
-
Field Details
-
METADATA
-
EXPECTED_TYPES
-
flushTask
-
inputClosedSeenErrorOnRead
private boolean inputClosedSeenErrorOnRead
-
-
Constructor Details
-
AbstractNioByteChannel
Create a new instance- Parameters:
parent
- the parentChannel
by which this instance was created. May benull
ch
- the underlyingSelectableChannel
on which it operates
-
-
Method Details
-
shutdownInput
Shutdown the input side of the channel. -
isInputShutdown0
protected boolean isInputShutdown0() -
newUnsafe
Description copied from class:AbstractChannel
Create a newAbstractChannel.AbstractUnsafe
instance which will be used for the life-time of theChannel
- Specified by:
newUnsafe
in classAbstractChannel
-
metadata
Description copied from interface:Channel
-
shouldBreakReadReady
-
isAllowHalfClosure
-
doWrite0
Write objects to the OS.- Parameters:
in
- the collection which contains objects to write.- 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
- 0 - if no write was attempted. This is appropriate if an empty
- Throws:
Exception
- if an I/O exception occurs during write.
-
doWriteInternal
- Throws:
Exception
-
doWrite
Description copied from class:AbstractChannel
Flush the content of the given buffer to the remote peer.- Specified by:
doWrite
in classAbstractChannel
- Throws:
Exception
-
filterOutboundMessage
Description copied from class:AbstractChannel
Invoked when a new message is added to aChannelOutboundBuffer
of thisAbstractChannel
, so that theChannel
implementation converts the message to another. (e.g. heap buffer -> direct buffer)- Overrides:
filterOutboundMessage
in classAbstractChannel
-
incompleteWrite
protected final void incompleteWrite(boolean setOpWrite) -
doWriteFileRegion
Write aFileRegion
- Parameters:
region
- theFileRegion
from which the bytes should be written- Returns:
- amount the amount of written bytes
- Throws:
Exception
-
doReadBytes
Read bytes into the givenByteBuf
and return the amount.- Throws:
Exception
-
doWriteBytes
-
setOpWrite
protected final void setOpWrite() -
clearOpWrite
protected final void clearOpWrite()
-