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

public final Class EpollServerSocketChannel

extends AbstractEpollChannel<UnixChannel>
implements ServerSocketChannel
Class Inheritance
All Implemented Interfaces
io.netty5.channel.socket.ServerSocketChannel, io.netty5.channel.ServerChannel, io.netty5.channel.Channel, io.netty5.channel.IoHandle, java.lang.Comparable, io.netty5.channel.ChannelOutboundInvoker, io.netty5.util.concurrent.FuturePromiseFactory, io.netty5.util.AttributeMap
Imports
io.netty5.buffer.Buffer, io.netty5.channel.Channel, .ChannelException, .ChannelOption, .ChannelShutdownDirection, .EventLoop, .EventLoopGroup, .ServerChannelReadHandleFactory, .ServerChannelWriteHandleFactory, io.netty5.channel.socket.DomainSocketAddress, .ServerSocketChannel, .SocketProtocolFamily, io.netty5.channel.unix.IntegerUnixChannelOption, .RawUnixChannelOption, .UnixChannel, .UnixChannelOption, io.netty5.util.NetUtil, io.netty5.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.io.File, .IOException, java.net.InetAddress, .ProtocolFamily, .SocketAddress, java.util.Collection, .Collections, .Map, .Set

ServerSocketChannel implementation that uses linux EPOLL Edge-Triggered Mode for maximal performance.

Available options

In addition to the options provided by ServerSocketChannel and UnixChannel, EpollServerSocketChannel allows the following options in the option map:
ChannelOption INET INET6 UNIX
IntegerUnixChannelOptionXXX
RawUnixChannelOptionXXX
UnixChannelOption#SO_REUSEPORTXX-
EpollChannelOption#IP_FREEBINDXX-
EpollChannelOption#TCP_DEFER_ACCEPTXX-
ChannelOption#TCP_FASTOPENXX-

Field Summary

Modifier and TypeField and Description
private final byte[]
private volatile int
private final EventLoopGroup
private static final InternalLogger
private volatile int
private static final Set<ChannelOption<?>>
private static final Set<ChannelOption<?>>
private volatile Collection<InetAddress>
Inherited from io.netty5.channel.epoll.AbstractEpollChannel:
activesocket

Constructor Summary

AccessConstructor and Description
public
EpollServerSocketChannel(EventLoop eventLoop, EventLoopGroup childEventLoopGroup)

public
EpollServerSocketChannel(EventLoop eventLoop, EventLoopGroup childEventLoopGroup, ProtocolFamily protocolFamily)

public
EpollServerSocketChannel(EventLoop eventLoop, EventLoopGroup childEventLoopGroup, int fd, ProtocolFamily protocolFamily)

private
EpollServerSocketChannel(EventLoop eventLoop, EventLoopGroup childEventLoopGroup, LinuxSocket socket)

Method Summary

Modifier and TypeMethod and Description
public EventLoopGroup
childEventLoopGroup()

Implements io.netty5.channel.ServerChannel.childEventLoopGroup.

Returns the EventLoopGroup that is used to register the child Channels on after accepting these.
protected void
protected void
protected boolean
doConnect(SocketAddress
the address of the remote peer.
remoteAddress
,
SocketAddress
the local address of this channel.
localAddress
,
Buffer
the initial data that is written during connect (if ChannelOption#TCP_FASTOPEN_CONNECT is supported and configured). If data is written care must be taken to update the reader offset.
initialData
)

Overrides io.netty5.channel.epoll.AbstractEpollChannel.doConnect.

Connect to the remote peer
protected boolean
doFinishConnect(SocketAddress
the remote address of the peer.
requestedRemoteAddress
)

Overrides io.netty5.channel.epoll.AbstractEpollChannel.doFinishConnect.

Finish a connect request.
protected void
doShutdown(ChannelShutdownDirection
the direction to shut down.
direction
)

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

Shutdown one direction of the Channel.
protected void
doWriteNow(AbstractChannel<UnixChannel, 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.
writeHandle
)

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 AbstractEpollChannel.ReadState
epollInReady(AbstractChannel<UnixChannel, SocketAddress, SocketAddress>.ReadSink readSink)

Implements abstract io.netty5.channel.epoll.AbstractEpollChannel.epollInReady.

Called once EPOLLIN event is ready to be processed
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.
private int
protected <T> T
private int
private int
private int
getTcpFastopen()

Returns threshold value of number of pending for fast open connect.

protected boolean
private boolean
private static 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 Channel
newChildChannel(int fd, byte[] address, int offset, int len)

private void
setBacklog(int backlog)

protected <T> void
private void
setIpFreebind(boolean reusePort)

private void
setReceiveBufferSize(int receiveBufferSize)

private void
setReuseAddress(boolean reuseAddress)

private void
setReusePort(boolean reusePort)

private void
setTcpDeferAccept(int deferAccept)

private void
setTcpFastopen(int
number of requests to be pending for fastopen at a given point in time for security.
pendingFastOpenRequestsThreshold
)

Enables tcpFastOpen on the server channel.

private void
setTcpMd5Sig(Map<InetAddress, byte[]> keys)

private static Set<ChannelOption<?>>
private static Set<ChannelOption<?>>
pack-priv Collection<InetAddress>
Inherited from io.netty5.channel.epoll.AbstractEpollChannel:
checkResolvableclearFlagcloseTransportNowderegister0doClearScheduledReaddoConnect0doDisconnectdoReaddoReadBytesdoReadNowdoWriteBytesdoWriteOrSendBytesepollInReadyepollOutReadyepollRdHupReadyfdfetchLocalAddressflagsisActiveisOpenisSoErrorZeroisWriteFlushedScheduledlocalAddress0newDirectBuffernewDirectBufferreadBufferAllocatorreadLoopCompleteregister0registrationremoteAddress0resetCachedAddressessetFlagwriteLoopComplete

Field Detail

acceptedAddressback to summary
private final byte[] acceptedAddress
backlogback to summary
private volatile int backlog
childEventLoopGroupback to summary
private final EventLoopGroup childEventLoopGroup
loggerback to summary
private static final InternalLogger logger

Hides io.netty5.channel.AbstractChannel.logger.

pendingFastOpenRequestsThresholdback to summary
private volatile int pendingFastOpenRequestsThreshold
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
tcpMd5SigAddressesback to summary
private volatile Collection<InetAddress> tcpMd5SigAddresses

Constructor Detail

EpollServerSocketChannelback to summary
public EpollServerSocketChannel(EventLoop eventLoop, EventLoopGroup childEventLoopGroup)
EpollServerSocketChannelback to summary
public EpollServerSocketChannel(EventLoop eventLoop, EventLoopGroup childEventLoopGroup, ProtocolFamily protocolFamily)
EpollServerSocketChannelback to summary
public EpollServerSocketChannel(EventLoop eventLoop, EventLoopGroup childEventLoopGroup, int fd, ProtocolFamily protocolFamily)
EpollServerSocketChannelback to summary
private EpollServerSocketChannel(EventLoop eventLoop, EventLoopGroup childEventLoopGroup, LinuxSocket socket)

Method Detail

childEventLoopGroupback to summary
public EventLoopGroup childEventLoopGroup()

Implements io.netty5.channel.ServerChannel.childEventLoopGroup.

Doc from io.netty5.channel.ServerChannel.childEventLoopGroup.

Returns the EventLoopGroup that is used to register the child Channels on after accepting these.

Annotations
@Override
doBindback to summary
protected void doBind(SocketAddress localAddress) throws Exception

Overrides io.netty5.channel.epoll.AbstractEpollChannel.doBind.

Doc from io.netty5.channel.AbstractChannel.doBind.

Bind the Channel to the SocketAddress

Parameters
localAddress:SocketAddress

the SocketAddress to bound to.

Annotations
@Override
Exceptions
Exception:
when an error happens.
doCloseback to summary
protected void doClose() throws Exception

Overrides io.netty5.channel.epoll.AbstractEpollChannel.doClose.

Doc from io.netty5.channel.AbstractChannel.doClose.

Close the Channel

Annotations
@Override
Exceptions
Exception:
thrown on error.
doConnectback to summary
protected boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress, Buffer initialData)

Overrides io.netty5.channel.epoll.AbstractEpollChannel.doConnect.

Doc from io.netty5.channel.epoll.AbstractEpollChannel.doConnect.

Connect to the remote peer

Parameters
remoteAddress:SocketAddress

Doc from io.netty5.channel.AbstractChannel.doConnect.

the address of the remote peer.

localAddress:SocketAddress

Doc from io.netty5.channel.AbstractChannel.doConnect.

the local address of this channel.

initialData:Buffer

Doc from io.netty5.channel.AbstractChannel.doConnect.

the initial data that is written during connect (if ChannelOption#TCP_FASTOPEN_CONNECT is supported and configured). If data is written care must be taken to update the reader offset.

Returns:boolean

Doc from io.netty5.channel.AbstractChannel.doConnect.

true if the connect operation was completed, false if finishConnect() will be called later again to try finish connecting.

Annotations
@Override
doFinishConnectback to summary
protected boolean doFinishConnect(SocketAddress requestedRemoteAddress)

Overrides io.netty5.channel.epoll.AbstractEpollChannel.doFinishConnect.

Doc from io.netty5.channel.AbstractChannel.doFinishConnect.

Finish a connect request. This method should never be directly called, use finishConnect() instead.

Parameters
requestedRemoteAddress:SocketAddress

the remote address of the peer.

Returns:boolean

true if the connect operations was completed, false if finishConnect() will be called later again to try finishing the connect operation.

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

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
doWriteNowback to summary
protected void doWriteNow(AbstractChannel<UnixChannel, SocketAddress, SocketAddress>.WriteSink writeHandle)

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
writeHandle:AbstractChannel<UnixChannel, 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
epollInReadyback to summary
protected AbstractEpollChannel.ReadState epollInReady(AbstractChannel<UnixChannel, SocketAddress, SocketAddress>.ReadSink readSink) throws Exception

Implements abstract io.netty5.channel.epoll.AbstractEpollChannel.epollInReady.

Doc from io.netty5.channel.epoll.AbstractEpollChannel.epollInReady.

Called once EPOLLIN event is ready to be processed

Annotations
@Override
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
getBacklogback to summary
private int getBacklog()
getExtendedOptionback to summary
protected <T> T getExtendedOption(ChannelOption<T> option)

Overrides io.netty5.channel.epoll.AbstractEpollChannel.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
getReceiveBufferSizeback to summary
private int getReceiveBufferSize()
getTcpDeferAcceptback to summary
private int getTcpDeferAccept()
getTcpFastopenback to summary
private int getTcpFastopen()

Returns threshold value of number of pending for fast open connect.

See Also
RFC 7413 Passive Open
isExtendedOptionSupportedback to summary
protected boolean isExtendedOptionSupported(ChannelOption<?> option)

Overrides io.netty5.channel.epoll.AbstractEpollChannel.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
isIpFreebindback to summary
private boolean isIpFreebind()
isOptionSupportedback to summary
private static boolean isOptionSupported(SocketProtocolFamily family, ChannelOption<?> option)
isReuseAddressback to summary
private boolean isReuseAddress()
isReusePortback to summary
private boolean isReusePort()
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
newChildChannelback to summary
private Channel newChildChannel(int fd, byte[] address, int offset, int len)
setBacklogback to summary
private void setBacklog(int backlog)
setExtendedOptionback to summary
protected <T> void setExtendedOption(ChannelOption<T> option, T value)

Overrides io.netty5.channel.epoll.AbstractEpollChannel.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
@SuppressWarnings:unchecked
@Override
setIpFreebindback to summary
private void setIpFreebind(boolean reusePort)
setReceiveBufferSizeback to summary
private void setReceiveBufferSize(int receiveBufferSize)
setReuseAddressback to summary
private void setReuseAddress(boolean reuseAddress)
setReusePortback to summary
private void setReusePort(boolean reusePort)
setTcpDeferAcceptback to summary
private void setTcpDeferAccept(int deferAccept)
setTcpFastopenback to summary
private void setTcpFastopen(int pendingFastOpenRequestsThreshold)

Enables tcpFastOpen on the server channel. If the underlying os doesn't support TCP_FASTOPEN setting this has no effect. This has to be set before doing listen on the socket otherwise this takes no effect.

Parameters
pendingFastOpenRequestsThreshold:int

number of requests to be pending for fastopen at a given point in time for security.

See Also
RFC 7413 Passive Open
setTcpMd5Sigback to summary
private void setTcpMd5Sig(Map<InetAddress, byte[]> keys)
supportedOptionsback to summary
private static Set<ChannelOption<?>> supportedOptions()

Hides io.netty5.channel.AbstractChannel.supportedOptions.

supportedOptionsDomainSocketback to summary
private static Set<ChannelOption<?>> supportedOptionsDomainSocket()
tcpMd5SigAddressesback to summary
pack-priv Collection<InetAddress> tcpMd5SigAddresses()