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

public Class NioServerSocketChannel

extends AbstractNioMessageChannel
implements ServerSocketChannel
Class Inheritance
All Implemented Interfaces
io.netty.channel.socket.ServerSocketChannel, io.netty.channel.ServerChannel, io.netty.channel.Channel, java.lang.Comparable, io.netty.channel.ChannelOutboundInvoker, io.netty.util.AttributeMap
Imports
io.netty.channel.ChannelException, .ChannelMetadata, .ChannelOption, .ChannelOutboundBuffer, io.netty.channel.socket.InternetProtocolFamily, .DefaultServerSocketChannelConfig, .ServerSocketChannelConfig, io.netty.util.internal.SocketUtils, .PlatformDependent, .SuppressJava6Requirement, io.netty.channel.nio.AbstractNioMessageChannel, io.netty.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.io.IOException, java.lang.reflect.Method, java.net.InetSocketAddress, .ServerSocket, .SocketAddress, java.nio.channels.SelectionKey, .ServerSocketChannel, .SocketChannel, java.nio.channels.spi.SelectorProvider, java.util.List, .Map

A io.netty.channel.socket.ServerSocketChannel implementation which uses NIO selector based implementation to accept new connections.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final ServerSocketChannelConfig
private static final SelectorProvider
private static final InternalLogger
private static final ChannelMetadata
private static final Method

Constructor Summary

AccessConstructor and Description
public
NioServerSocketChannel()

Create a new instance

public
NioServerSocketChannel(SelectorProvider provider)

Create a new instance using the given SelectorProvider.

public
NioServerSocketChannel(SelectorProvider provider, InternetProtocolFamily family)

Create a new instance using the given SelectorProvider and protocol family (supported only since JDK 15).

public
NioServerSocketChannel(ServerSocketChannel channel)

Create a new instance using the given ServerSocketChannel.

Method Summary

Modifier and TypeMethod and Description
protected boolean
public ServerSocketChannelConfig
config()

Implements io.netty.channel.socket.ServerSocketChannel.config, io.netty.channel.Channel.config.

Returns the configuration of this channel.
protected void
doBind(SocketAddress localAddress)

Implements abstract io.netty.channel.AbstractChannel.doBind.

Bind the Channel to the SocketAddress
protected void
protected boolean
doConnect(SocketAddress remoteAddress, SocketAddress localAddress)

Implements abstract io.netty.channel.nio.AbstractNioChannel.doConnect.

Connect to the remote peer
protected void
doDisconnect()

Implements abstract io.netty.channel.AbstractChannel.doDisconnect.

Disconnect this Channel from its remote peer
protected void
protected int
doReadMessages(List<Object> buf)

Implements abstract io.netty.channel.nio.AbstractNioMessageChannel.doReadMessages.

Read messages into the given array and return the amount which was read.
protected boolean
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.
public boolean
isActive()

Implements io.netty.channel.Channel.isActive.

Return true if the Channel is active and so connected.
protected ServerSocketChannel
public InetSocketAddress
protected SocketAddress
localAddress0()

Implements abstract io.netty.channel.AbstractChannel.localAddress0.

Returns the SocketAddress which is bound locally.
public ChannelMetadata
metadata()

Implements io.netty.channel.Channel.metadata.

Return the ChannelMetadata of the Channel which describe the nature of the Channel.
private static ServerSocketChannel
public InetSocketAddress
protected SocketAddress
remoteAddress0()

Implements abstract io.netty.channel.AbstractChannel.remoteAddress0.

Return the SocketAddress which the Channel is connected to.
Inherited from io.netty.channel.nio.AbstractNioMessageChannel:
continueOnWriteErrorcontinueReadingdoBeginReaddoWritenewUnsafe

Field Detail

configback to summary
private final ServerSocketChannelConfig config
DEFAULT_SELECTOR_PROVIDERback to summary
private static final SelectorProvider DEFAULT_SELECTOR_PROVIDER
loggerback to summary
private static final InternalLogger logger

Hides io.netty.channel.nio.AbstractNioChannel.logger.

METADATAback to summary
private static final ChannelMetadata METADATA
OPEN_SERVER_SOCKET_CHANNEL_WITH_FAMILYback to summary
private static final Method OPEN_SERVER_SOCKET_CHANNEL_WITH_FAMILY

Constructor Detail

NioServerSocketChannelback to summary
public NioServerSocketChannel()

Create a new instance

NioServerSocketChannelback to summary
public NioServerSocketChannel(SelectorProvider provider)

Create a new instance using the given SelectorProvider.

NioServerSocketChannelback to summary
public NioServerSocketChannel(SelectorProvider provider, InternetProtocolFamily family)

Create a new instance using the given SelectorProvider and protocol family (supported only since JDK 15).

NioServerSocketChannelback to summary
public NioServerSocketChannel(ServerSocketChannel channel)

Create a new instance using the given ServerSocketChannel.

Method Detail

closeOnReadErrorback to summary
protected boolean closeOnReadError(Throwable cause)

Overrides io.netty.channel.nio.AbstractNioMessageChannel.closeOnReadError.

Annotations
@Override
configback to summary
public ServerSocketChannelConfig config()

Implements io.netty.channel.socket.ServerSocketChannel.config, io.netty.channel.Channel.config.

Doc from io.netty.channel.Channel.config.

Returns the configuration of this channel.

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

Implements abstract io.netty.channel.AbstractChannel.doBind.

Doc from io.netty.channel.AbstractChannel.doBind.

Bind the Channel to the SocketAddress

Annotations
@SuppressJava6Requirement
reason:Usage guarded by java version check
@Override
doCloseback to summary
protected void doClose() throws Exception

Overrides io.netty.channel.nio.AbstractNioChannel.doClose.

Doc from io.netty.channel.AbstractChannel.doClose.

Close the Channel

Annotations
@Override
doConnectback to summary
protected boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception

Implements abstract io.netty.channel.nio.AbstractNioChannel.doConnect.

Doc from io.netty.channel.nio.AbstractNioChannel.doConnect.

Connect to the remote peer

Annotations
@Override
doDisconnectback to summary
protected void doDisconnect() throws Exception

Implements abstract io.netty.channel.AbstractChannel.doDisconnect.

Doc from io.netty.channel.AbstractChannel.doDisconnect.

Disconnect this Channel from its remote peer

Annotations
@Override
doFinishConnectback to summary
protected void doFinishConnect() throws Exception

Implements abstract io.netty.channel.nio.AbstractNioChannel.doFinishConnect.

Doc from io.netty.channel.nio.AbstractNioChannel.doFinishConnect.

Finish the connect

Annotations
@Override
doReadMessagesback to summary
protected int doReadMessages(List<Object> buf) throws Exception

Implements abstract io.netty.channel.nio.AbstractNioMessageChannel.doReadMessages.

Doc from io.netty.channel.nio.AbstractNioMessageChannel.doReadMessages.

Read messages into the given array and return the amount which was read.

Annotations
@Override
doWriteMessageback to summary
protected boolean doWriteMessage(Object msg, ChannelOutboundBuffer in) throws Exception

Implements abstract io.netty.channel.nio.AbstractNioMessageChannel.doWriteMessage.

Doc from io.netty.channel.nio.AbstractNioMessageChannel.doWriteMessage.

Write a message to the underlying java.nio.channels.Channel.

Returns:boolean

true if and only if the message has been written

Annotations
@Override
filterOutboundMessageback to summary
protected final Object filterOutboundMessage(Object msg) throws Exception

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
isActiveback to summary
public boolean isActive()

Implements io.netty.channel.Channel.isActive.

Doc from io.netty.channel.Channel.isActive.

Return true if the Channel is active and so connected.

Annotations
@Override
javaChannelback to summary
protected ServerSocketChannel javaChannel()

Overrides io.netty.channel.nio.AbstractNioChannel.javaChannel.

Annotations
@Override
localAddressback to summary
public InetSocketAddress localAddress()

Overrides io.netty.channel.AbstractChannel.localAddress.

Implements io.netty.channel.socket.ServerSocketChannel.localAddress, io.netty.channel.Channel.localAddress.

Doc from io.netty.channel.Channel.localAddress.

Returns the local address where this channel is bound to. The returned SocketAddress is supposed to be down-cast into more concrete type such as InetSocketAddress to retrieve the detailed information.

Returns:InetSocketAddress

the local address of this channel. null if this channel is not bound.

Annotations
@Override
localAddress0back to summary
protected SocketAddress localAddress0()

Implements abstract io.netty.channel.AbstractChannel.localAddress0.

Doc from io.netty.channel.AbstractChannel.localAddress0.

Returns the SocketAddress which is bound locally.

Annotations
@Override
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
newChannelback to summary
private static ServerSocketChannel newChannel(SelectorProvider provider, InternetProtocolFamily family)
remoteAddressback to summary
public InetSocketAddress remoteAddress()

Overrides io.netty.channel.AbstractChannel.remoteAddress.

Implements io.netty.channel.socket.ServerSocketChannel.remoteAddress, io.netty.channel.Channel.remoteAddress.

Doc from io.netty.channel.Channel.remoteAddress.

Returns the remote address where this channel is connected to. The returned SocketAddress is supposed to be down-cast into more concrete type such as InetSocketAddress to retrieve the detailed information.

Returns:InetSocketAddress

the remote address of this channel. null if this channel is not connected. If this channel is not connected but it can receive messages from arbitrary remote addresses (e.g. DatagramChannel, use DatagramPacket#recipient() to determine the origination of the received message as this method will return null.

Annotations
@Override
remoteAddress0back to summary
protected SocketAddress remoteAddress0()

Implements abstract io.netty.channel.AbstractChannel.remoteAddress0.

Doc from io.netty.channel.AbstractChannel.remoteAddress0.

Return the SocketAddress which the Channel is connected to.

Annotations
@Override
io.netty.channel.socket.nio back to summary

private final Class NioServerSocketChannel.NioServerSocketChannelConfig

extends DefaultServerSocketChannelConfig
Class Inheritance

Field Summary

Inherited from io.netty.channel.socket.DefaultServerSocketChannelConfig:
javaSocket

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected void
autoReadCleared()

Overrides io.netty.channel.DefaultChannelConfig.autoReadCleared.

Is called once setAutoRead(boolean) is called with false and isAutoRead() was true before.
public <T> T
public Map<ChannelOption<?>, Object>
private ServerSocketChannel
public <T> boolean
setOption(ChannelOption<T> option, T value)

Overrides io.netty.channel.socket.DefaultServerSocketChannelConfig.setOption.

Implements io.netty.channel.ChannelConfig.setOption.

Sets a configuration property with the specified name and value.
Inherited from io.netty.channel.socket.DefaultServerSocketChannelConfig:
getBackloggetReceiveBufferSizeisReuseAddresssetAllocatorsetAutoReadsetBacklogsetConnectTimeoutMillissetMaxMessagesPerReadsetMessageSizeEstimatorsetPerformancePreferencessetReceiveBufferSizesetRecvByteBufAllocatorsetReuseAddresssetWriteBufferHighWaterMarksetWriteBufferLowWaterMarksetWriteBufferWaterMarksetWriteSpinCount

Constructor Detail

NioServerSocketChannelConfigback to summary
private NioServerSocketChannelConfig(NioServerSocketChannel channel, ServerSocket javaSocket)

Method Detail

autoReadClearedback to summary
protected void autoReadCleared()

Overrides io.netty.channel.DefaultChannelConfig.autoReadCleared.

Doc from io.netty.channel.DefaultChannelConfig.autoReadCleared.

Is called once setAutoRead(boolean) is called with false and isAutoRead() was true before.

Annotations
@Override
getOptionback to summary
public <T> T getOption(ChannelOption<T> option)

Overrides io.netty.channel.socket.DefaultServerSocketChannelConfig.getOption.

Implements io.netty.channel.ChannelConfig.getOption.

Doc from io.netty.channel.ChannelConfig.getOption.

Return the value of the given ChannelOption

Annotations
@Override
getOptionsback to summary
public Map<ChannelOption<?>, Object> getOptions()

Overrides io.netty.channel.socket.DefaultServerSocketChannelConfig.getOptions.

Implements io.netty.channel.ChannelConfig.getOptions.

Doc from io.netty.channel.ChannelConfig.getOptions.

Return all set ChannelOption's.

Annotations
@Override
jdkChannelback to summary
private ServerSocketChannel jdkChannel()
setOptionback to summary
public <T> boolean setOption(ChannelOption<T> option, T value)

Overrides io.netty.channel.socket.DefaultServerSocketChannelConfig.setOption.

Implements io.netty.channel.ChannelConfig.setOption.

Doc from io.netty.channel.ChannelConfig.setOption.

Sets a configuration property with the specified name and value. To override this method properly, you must call the super class:

public boolean setOption(ChannelOption<T> option, T value) {
    if (super.setOption(option, value)) {
        return true;
    }

    if (option.equals(additionalOption)) {
        ....
        return true;
    }

    return false;
}
Returns:boolean

true if and only if the property has been set

Annotations
@Override