Top Description Fields Constructors Methods
io.netty5.channel.nio

public abstract Class AbstractNioByteChannel<P extends Channel, L extends SocketAddress, R extends SocketAddress>

extends AbstractNioChannel<P extends Channel, L extends SocketAddress, R extends SocketAddress>
Class Inheritance
Known Direct Subclasses
io.netty5.channel.socket.nio.NioSocketChannel
Imports
io.netty5.buffer.Buffer, io.netty5.channel.AdaptiveReadHandleFactory, .WriteHandleFactory, .Channel, .EventLoop, .FileRegion, io.netty5.util.Resource, io.netty5.util.internal.StringUtil, java.net.SocketAddress, java.nio.channels.SelectableChannel, .SelectionKey

AbstractNioChannel base class for Channels that operate on bytes.

Field Summary

Modifier and TypeField and Description
private static final String

Constructor Summary

AccessConstructor and Description
protected
AbstractNioByteChannel(P
the parent Channel by which this instance was created. May be null
parent
,
EventLoop
the EventLoop to use for IO.
eventLoop
,
WriteHandleFactory
the WriteHandleFactory that is used by default.
defaultWriteHandleFactory
,
SelectableChannel
the underlying SelectableChannel on which it operates
ch
)

Create a new instance

Method Summary

Modifier and TypeMethod and Description
protected abstract int
doReadBytes(Buffer buf)

Read bytes into the given Buffer and return the amount.

protected final boolean
doReadNow(AbstractChannel<P, L, R>.ReadSink
the ReadSink that should be called with messages that are read from the transport to propagate these.
readSink
)

Implements abstract io.netty5.channel.AbstractChannel.doReadNow.

Try to read a message from the transport and dispatch it via ReadSink#processRead(int, int, Object).
protected abstract int

Returns:

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

Write bytes form the given Buffer 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

protected void
doWriteNow(AbstractChannel<P, L, R>.WriteSink
the WriteSink that must be completed with the write progress. WriteSink#complete(long, long, int, boolean) or WriteSink#complete(long, Throwable, boolean) must be called exactly once before this method returns non-exceptional.
writeSink
)

Implements abstract io.netty5.channel.AbstractChannel.doWriteNow.

Called in a loop when writes should be performed until this method returns false or there are no more messages to write.
protected final Object
filterOutboundMessage(Object
the message to filter / convert.
msg
)

Overrides io.netty5.channel.AbstractChannel.filterOutboundMessage.

Invoked when a new message is added to to the outbound queue of this AbstractChannel, so that the Channel implementation converts the message to another.
Inherited from io.netty5.channel.nio.AbstractNioChannel:
doClearScheduledReaddoClosedoReadisOpenisWriteFlushedScheduledjavaChannelnewDirectBuffernewDirectBuffernioProcessorselectionKeywriteLoopComplete

Field Detail

EXPECTED_TYPESback to summary
private static final String EXPECTED_TYPES

Constructor Detail

AbstractNioByteChannelback to summary
protected AbstractNioByteChannel(P parent, EventLoop eventLoop, WriteHandleFactory defaultWriteHandleFactory, SelectableChannel ch)

Create a new instance

Parameters
parent:P

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

eventLoop:EventLoop

the EventLoop to use for IO.

defaultWriteHandleFactory:WriteHandleFactory

the WriteHandleFactory that is used by default.

ch:SelectableChannel

the underlying SelectableChannel on which it operates

Method Detail

doReadBytesback to summary
protected abstract int doReadBytes(Buffer buf) throws Exception

Read bytes into the given Buffer and return the amount.

doReadNowback to summary
protected final boolean doReadNow(AbstractChannel<P, L, R>.ReadSink readSink) throws Exception

Implements abstract io.netty5.channel.AbstractChannel.doReadNow.

Doc from io.netty5.channel.AbstractChannel.doReadNow.

Try to read a message from the transport and dispatch it via ReadSink#processRead(int, int, Object). This method is called in a loop until there is nothing more messages to read or the channel was shutdown / closed. This method should never be called directly by sub-classes, use readNow() instead.

Parameters
readSink:AbstractChannel<P, L, R>.ReadSink

the ReadSink that should be called with messages that are read from the transport to propagate these.

Returns:boolean

true if the channel should be shutdown / closed.

Annotations
@Override
doWriteBytesback to summary
protected abstract int doWriteBytes(Buffer buf) throws Exception

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

Parameters
buf:Buffer

the Buffer 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

doWriteNowback to summary
protected void doWriteNow(AbstractChannel<P, L, R>.WriteSink writeSink) throws Exception

Implements abstract io.netty5.channel.AbstractChannel.doWriteNow.

Doc from io.netty5.channel.AbstractChannel.doWriteNow.

Called in a loop when writes should be performed until this method returns false or there are no more messages to write. Implementations are responsible for handling partial writes, which for example means that if Buffers are written partial implementations need to ensure the readerOffset is updated accordingly.

Parameters
writeSink:AbstractChannel<P, L, R>.WriteSink

the WriteSink that must be completed with the write progress. WriteSink#complete(long, long, int, boolean) or WriteSink#complete(long, Throwable, boolean) must be called exactly once before this method returns non-exceptional.

Annotations
@Override
Exceptions
Exception:
if an error happened during writing. This will also terminate the write loop.
filterOutboundMessageback to summary
protected final Object filterOutboundMessage(Object msg)

Overrides io.netty5.channel.AbstractChannel.filterOutboundMessage.

Doc from io.netty5.channel.AbstractChannel.filterOutboundMessage.

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

Parameters
msg:Object

the message to filter / convert.

Annotations
@Override