Top Description Inners Fields Constructors Methods
io.netty5.channel.kqueue

public final Class KQueueSocketChannel

extends AbstractKQueueChannel<KQueueServerSocketChannel>
implements SocketChannel
Class Inheritance
All Implemented Interfaces
io.netty5.channel.socket.SocketChannel, io.netty5.channel.Channel, io.netty5.channel.IoHandle, java.lang.Comparable, io.netty5.channel.ChannelOutboundInvoker, io.netty5.util.concurrent.FuturePromiseFactory, io.netty5.util.AttributeMap
Annotations
@UnstableApi
Imports
io.netty5.buffer.Buffer, .BufferAllocator, io.netty5.channel.AdaptiveReadHandleFactory, .ChannelException, .ChannelOption, .ChannelShutdownDirection, .DefaultFileRegion, .EventLoop, .FileRegion, io.netty5.channel.socket.SocketChannel, .SocketChannelWriteHandleFactory, .SocketProtocolFamily, io.netty5.channel.unix.DomainSocketReadMode, .FileDescriptor, .IntegerUnixChannelOption, .IovArray, .PeerCredentials, .RawUnixChannelOption, .SocketWritableByteChannel, .UnixChannel, .UnixChannelOption, .UnixChannelUtil, io.netty5.util.Resource, io.netty5.util.concurrent.Future, .GlobalEventExecutor, io.netty5.util.internal.PlatformDependent, .StringUtil, .UnstableApi, java.io.IOException, java.net.InetSocketAddress, .ProtocolFamily, .SocketAddress, java.nio.ByteBuffer, java.nio.channels.NotYetConnectedException, .WritableByteChannel, java.util.Set, java.util.concurrent.Executor

SocketChannel implementation that uses KQueue.

Available options

In addition to the options provided by SocketChannel and UnixChannel, KQueueSocketChannel allows the following options in the option map:
ChannelOption INET INET6 UNIX
IntegerUnixChannelOptionXXX
RawUnixChannelOptionXXX
KQueueChannelOption#SO_SNDLOWATXX-
KQueueChannelOption#TCP_NOPUSHXX-
ChannelOption#TCP_FASTOPEN_CONNECTXX-

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private WritableByteChannel
private static final String
private volatile DomainSocketReadMode
private static final Set<ChannelOption<?>>
private static final Set<ChannelOption<?>>
private volatile boolean
Inherited from io.netty5.channel.kqueue.AbstractKQueueChannel:
activesocket

Constructor Summary

AccessConstructor and Description
public
public
KQueueSocketChannel(EventLoop eventLoop, ProtocolFamily protocolFamily)

public
KQueueSocketChannel(EventLoop eventLoop, int fd, ProtocolFamily protocolFamily)

private
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected boolean
protected void
doShutdown(ChannelShutdownDirection
the direction to shut down.
direction
)

Implements abstract io.netty5.channel.AbstractChannel.doShutdown.

Shutdown one direction of the Channel.
private void
protected void
doWriteNow(AbstractChannel<KQueueServerSocketChannel, SocketAddress, SocketAddress>.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.
private void
private void
protected 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.
protected <T> T
private PeerCredentials
private DomainSocketReadMode
private int
private int
private int
private int
private int
protected boolean
private boolean
private boolean
public boolean
isShutdown(ChannelShutdownDirection direction)

Implements io.netty5.channel.Channel.isShutdown.

Returns true if the ChannelShutdownDirection of the Channel was shutdown before.
private boolean
isSupported(SocketProtocolFamily protocolFamily, ChannelOption<?> option)

private boolean
isTcpFastOpenConnect()

Returns true if TCP fast open is enabled, false otherwise.

private boolean
private boolean
protected Future<Executor>
pack-priv int
private int
private int
protected <T> void
private void
setKeepAlive(boolean keepAlive)

private void
private void
setReceiveBufferSize(int receiveBufferSize)

private void
setReuseAddress(boolean reuseAddress)

private void
setSendBufferSize(int sendBufferSize)

private void
setSndLowAt(int sndLowAt)

private void
setSoLinger(int soLinger)

private void
setTcpFastOpenConnect(boolean fastOpenConnect)

Enables client TCP fast open, if available.

private void
setTcpNoDelay(boolean tcpNoDelay)

private void
setTcpNoPush(boolean tcpNoPush)

private void
setTrafficClass(int trafficClass)

private static Set<ChannelOption<?>>
private static Set<ChannelOption<?>>
private void
private long

Returns:

number of written bytes.
writeBytesMultiple
(IovArray
The array which contains the content to write.
array
)

Write multiple bytes via IovArray.

private long

Returns:

number of written bytes.
writeBytesMultiple
(ByteBuffer[]
The buffers to write.
nioBuffers
,
int
The number of buffers to write.
nioBufferCnt
,
long
The number of bytes we expect to write.
expectedWrittenBytes
,
long
The maximum number of bytes we should attempt to write.
maxBytesPerGatheringWrite
)

Write multiple bytes via ByteBuffer array.

private void
private void
Inherited from io.netty5.channel.kqueue.AbstractKQueueChannel:
checkResolvablecloseTransportNowderegister0doBinddoClearScheduledReaddoClosedoConnectdoDisconnectdoFinishConnectdoReaddoReadBytesdoReadNowdoWriteBytesfdfetchLocalAddressisActiveisOpenisSoErrorZeroisWriteFlushedScheduledlocalAddress0newDirectBuffernewDirectBufferreadBufferAllocatorreadEOFreadFilterreadLoopCompletereadReadyregister0registrationremoteAddress0resetCachedAddressesunregisterFilterswriteFilterwriteLoopCompletewriteReady

Field Detail

byteChannelback to summary
private WritableByteChannel byteChannel
EXPECTED_TYPESback to summary
private static final String EXPECTED_TYPES
modeback to summary
private volatile DomainSocketReadMode mode
SUPPORTED_OPTIONSback to summary
private static final Set<ChannelOption<?>> SUPPORTED_OPTIONS
SUPPORTED_OPTIONS_DOMAIN_SOCKETback to summary
private static final Set<ChannelOption<?>> SUPPORTED_OPTIONS_DOMAIN_SOCKET
tcpFastopenback to summary
private volatile boolean tcpFastopen

Constructor Detail

KQueueSocketChannelback to summary
public KQueueSocketChannel(EventLoop eventLoop)
KQueueSocketChannelback to summary
public KQueueSocketChannel(EventLoop eventLoop, ProtocolFamily protocolFamily)
KQueueSocketChannelback to summary
public KQueueSocketChannel(EventLoop eventLoop, int fd, ProtocolFamily protocolFamily)
KQueueSocketChannelback to summary
private KQueueSocketChannel(EventLoop eventLoop, BsdSocket fd)
KQueueSocketChannelback to summary
pack-priv KQueueSocketChannel(KQueueServerSocketChannel parent, EventLoop eventLoop, BsdSocket fd, SocketAddress remoteAddress)

Method Detail

doConnect0back to summary
protected boolean doConnect0(SocketAddress remoteAddress, SocketAddress localAddress, Buffer initialData) throws Exception

Overrides io.netty5.channel.kqueue.AbstractKQueueChannel.doConnect0.

Annotations
@Override
doShutdownback to summary
protected void doShutdown(ChannelShutdownDirection direction) throws Exception

Implements abstract io.netty5.channel.AbstractChannel.doShutdown.

Doc from io.netty5.channel.AbstractChannel.doShutdown.

Shutdown one direction of the Channel.

Parameters
direction:ChannelShutdownDirection

the direction to shut down.

Annotations
@Override
Exceptions
Exception:
thrown on error.
doWriteMultipleback to summary
private void doWriteMultiple(AbstractChannel<KQueueServerSocketChannel, SocketAddress, SocketAddress>.WriteSink writeSink) throws Exception

Attempt to write multiple Buffer objects.

Parameters
writeSink:AbstractChannel<KQueueServerSocketChannel, SocketAddress, SocketAddress>.WriteSink

the WriteSink used.

Exceptions
Exception:
If an I/O error occurs.
doWriteNowback to summary
protected void doWriteNow(AbstractChannel<KQueueServerSocketChannel, SocketAddress, SocketAddress>.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<KQueueServerSocketChannel, SocketAddress, SocketAddress>.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.
doWriteSingleback to summary
private void doWriteSingle(AbstractChannel<KQueueServerSocketChannel, SocketAddress, SocketAddress>.WriteSink writeSink) throws Exception

Attempt to write a single object.

Parameters
writeSink:AbstractChannel<KQueueServerSocketChannel, SocketAddress, SocketAddress>.WriteSink

the WriteSink used.

Exceptions
Exception:
If an I/O error occurs.
enableTcpNoDelayIfSupportedback to summary
private void enableTcpNoDelayIfSupported()
filterOutboundMessageback to summary
protected 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
getExtendedOptionback to summary
protected <T> T getExtendedOption(ChannelOption<T> option)

Overrides io.netty5.channel.kqueue.AbstractKQueueChannel.getExtendedOption.

Doc from io.netty5.channel.AbstractChannel.getExtendedOption.

Override to add support for more ChannelOptions. You need to also call super after handling the extra options.

Parameters
<T>
the value type.
option:ChannelOption<T>

the ChannelOption.

Returns:T

the value for the option.

Annotations
@SuppressWarnings:unchecked
@Override
getPeerCredentialsback to summary
private PeerCredentials getPeerCredentials()
getReadModeback to summary
private DomainSocketReadMode getReadMode()
getReceiveBufferSizeback to summary
private int getReceiveBufferSize()
getSendBufferSizeback to summary
private int getSendBufferSize()
getSndLowAtback to summary
private int getSndLowAt()
getSoLingerback to summary
private int getSoLinger()
getTrafficClassback to summary
private int getTrafficClass()
isExtendedOptionSupportedback to summary
protected boolean isExtendedOptionSupported(ChannelOption<?> option)

Overrides io.netty5.channel.kqueue.AbstractKQueueChannel.isExtendedOptionSupported.

Doc from io.netty5.channel.AbstractChannel.isExtendedOptionSupported.

Override to add support for more ChannelOptions. You need to also call super after handling the extra options.

Parameters
option:ChannelOption<?>

the ChannelOption.

Returns:boolean

true if supported, false otherwise.

Annotations
@Override
isKeepAliveback to summary
private boolean isKeepAlive()
isReuseAddressback to summary
private boolean isReuseAddress()
isShutdownback to summary
public boolean isShutdown(ChannelShutdownDirection direction)

Implements io.netty5.channel.Channel.isShutdown.

Doc from io.netty5.channel.Channel.isShutdown.

Returns true if the ChannelShutdownDirection of the Channel was shutdown before.

Annotations
@Override
isSupportedback to summary
private boolean isSupported(SocketProtocolFamily protocolFamily, ChannelOption<?> option)
isTcpFastOpenConnectback to summary
private boolean isTcpFastOpenConnect()

Returns true if TCP fast open is enabled, false otherwise.

isTcpNoDelayback to summary
private boolean isTcpNoDelay()
isTcpNoPushback to summary
private boolean isTcpNoPush()
prepareToCloseback to summary
protected Future<Executor> prepareToClose()

Overrides io.netty5.channel.AbstractChannel.prepareToClose.

Doc from io.netty5.channel.AbstractChannel.prepareToClose.

Prepares to close the Channel. If this method returns an Executor, the caller must call the Executor#execute(Runnable) method with a task that calls doClose() on the returned Executor. If this method returns null, doClose() must be called from the caller thread. (i.e. EventLoop)

Annotations
@Override
readReadyback to summary
pack-priv int readReady(AbstractChannel<KQueueServerSocketChannel, SocketAddress, SocketAddress>.ReadSink readSink) throws Exception

Implements abstract io.netty5.channel.kqueue.AbstractKQueueChannel.readReady.

Annotations
@Override
readReadyBytesback to summary
private int readReadyBytes(AbstractChannel<KQueueServerSocketChannel, SocketAddress, SocketAddress>.ReadSink readSink) throws Exception
readReadyFdback to summary
private int readReadyFd(AbstractChannel<KQueueServerSocketChannel, SocketAddress, SocketAddress>.ReadSink readSink) throws Exception
setExtendedOptionback to summary
protected <T> void setExtendedOption(ChannelOption<T> option, T value)

Overrides io.netty5.channel.kqueue.AbstractKQueueChannel.setExtendedOption.

Doc from io.netty5.channel.AbstractChannel.setExtendedOption.

Override to add support for more ChannelOptions. You need to also call super after handling the extra options.

Parameters
<T>
the value type.
option:ChannelOption<T>

the ChannelOption.

Annotations
@Override
setKeepAliveback to summary
private void setKeepAlive(boolean keepAlive)
setReadModeback to summary
private void setReadMode(DomainSocketReadMode mode)
setReceiveBufferSizeback to summary
private void setReceiveBufferSize(int receiveBufferSize)
setReuseAddressback to summary
private void setReuseAddress(boolean reuseAddress)
setSendBufferSizeback to summary
private void setSendBufferSize(int sendBufferSize)
setSndLowAtback to summary
private void setSndLowAt(int sndLowAt)
setSoLingerback to summary
private void setSoLinger(int soLinger)
setTcpFastOpenConnectback to summary
private void setTcpFastOpenConnect(boolean fastOpenConnect)

Enables client TCP fast open, if available.

setTcpNoDelayback to summary
private void setTcpNoDelay(boolean tcpNoDelay)
setTcpNoPushback to summary
private void setTcpNoPush(boolean tcpNoPush)
setTrafficClassback to summary
private void setTrafficClass(int trafficClass)
supportedOptionsback to summary
private static Set<ChannelOption<?>> supportedOptions()

Hides io.netty5.channel.AbstractChannel.supportedOptions.

supportedOptionsDomainSocketback to summary
private static Set<ChannelOption<?>> supportedOptionsDomainSocket()
writeBytesback to summary
private void writeBytes(AbstractChannel<KQueueServerSocketChannel, SocketAddress, SocketAddress>.WriteSink writeSink) throws Exception

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

Parameters
writeSink:AbstractChannel<KQueueServerSocketChannel, SocketAddress, SocketAddress>.WriteSink

the WriteSink used.

writeBytesMultipleback to summary
private long writeBytesMultiple(IovArray array) throws IOException

Write multiple bytes via IovArray.

Parameters
array:IovArray

The array which contains the content to write.

Returns:long

number of written bytes.

Exceptions
IOException:
If an I/O exception occurs during write.
writeBytesMultipleback to summary
private long writeBytesMultiple(ByteBuffer[] nioBuffers, int nioBufferCnt, long expectedWrittenBytes, long maxBytesPerGatheringWrite) throws IOException

Write multiple bytes via ByteBuffer array.

Parameters
nioBuffers:ByteBuffer[]

The buffers to write.

nioBufferCnt:int

The number of buffers to write.

expectedWrittenBytes:long

The number of bytes we expect to write.

maxBytesPerGatheringWrite:long

The maximum number of bytes we should attempt to write.

Returns:long

number of written bytes.

Exceptions
IOException:
If an I/O exception occurs during write.
writeDefaultFileRegionback to summary
private void writeDefaultFileRegion(AbstractChannel<KQueueServerSocketChannel, SocketAddress, SocketAddress>.WriteSink writeSink) throws Exception

Write a DefaultFileRegion

Parameters
writeSink:AbstractChannel<KQueueServerSocketChannel, SocketAddress, SocketAddress>.WriteSink

the WriteSink used.

writeFileRegionback to summary
private void writeFileRegion(AbstractChannel<KQueueServerSocketChannel, SocketAddress, SocketAddress>.WriteSink writeSink) throws Exception

Write a FileRegion

Parameters
writeSink:AbstractChannel<KQueueServerSocketChannel, SocketAddress, SocketAddress>.WriteSink

the WriteSink used.

io.netty5.channel.kqueue back to summary

private final Class KQueueSocketChannel.KQueueSocketWritableByteChannel

extends SocketWritableByteChannel
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected BufferAllocator
Inherited from io.netty5.channel.unix.SocketWritableByteChannel:
closeisOpenwritewrite

Constructor Detail

KQueueSocketWritableByteChannelback to summary
pack-priv KQueueSocketWritableByteChannel()

Method Detail

allocback to summary
protected BufferAllocator alloc()

Implements abstract io.netty5.channel.unix.SocketWritableByteChannel.alloc.

Annotations
@Override