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

public final Class NioDatagramChannel

extends AbstractNioMessageChannel
implements DatagramChannel
Class Inheritance
All Implemented Interfaces
io.netty.channel.socket.DatagramChannel, io.netty.channel.Channel, java.lang.Comparable, io.netty.channel.ChannelOutboundInvoker, io.netty.util.AttributeMap
Imports
io.netty.buffer.ByteBuf, io.netty.channel.AddressedEnvelope, .Channel, .ChannelException, .ChannelFuture, .ChannelMetadata, .ChannelOption, .ChannelOutboundBuffer, .ChannelPromise, .DefaultAddressedEnvelope, .RecvByteBufAllocator, io.netty.channel.nio.AbstractNioMessageChannel, io.netty.channel.socket.DatagramChannelConfig, .DatagramPacket, .InternetProtocolFamily, io.netty.util.UncheckedBooleanSupplier, io.netty.util.internal.ObjectUtil, .SocketUtils, .PlatformDependent, .StringUtil, .SuppressJava6Requirement, java.io.IOException, java.net.InetAddress, .InetSocketAddress, .NetworkInterface, .SocketAddress, .SocketException, java.nio.ByteBuffer, java.nio.channels.DatagramChannel, .MembershipKey, .SelectionKey, .UnresolvedAddressException, java.nio.channels.spi.SelectorProvider, java.util.ArrayList, .HashMap, .Iterator, .List, .Map

An NIO datagram Channel that sends and receives an AddressedEnvelope<ByteBuf, SocketAddress>.
See Also
AddressedEnvelope, DatagramPacket

Field Summary

Modifier and TypeField and Description
private final DatagramChannelConfig
private static final SelectorProvider
private static final String
private Map<InetAddress, List<MembershipKey>>
private static final ChannelMetadata

Constructor Summary

AccessConstructor and Description
public
NioDatagramChannel()

Create a new instance which will use the Operation Systems default InternetProtocolFamily.

public
NioDatagramChannel(SelectorProvider provider)

Create a new instance using the given SelectorProvider which will use the Operation Systems default InternetProtocolFamily.

public
NioDatagramChannel(InternetProtocolFamily ipFamily)

Create a new instance using the given InternetProtocolFamily.

public
NioDatagramChannel(SelectorProvider provider, InternetProtocolFamily ipFamily)

Create a new instance using the given SelectorProvider and InternetProtocolFamily.

public
NioDatagramChannel(DatagramChannel socket)

Create a new instance from the given DatagramChannel.

Method Summary

Modifier and TypeMethod and Description
public ChannelFuture
block(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress sourceToBlock)

Implements io.netty.channel.socket.DatagramChannel.block.

Block the given sourceToBlock address for the given multicastAddress on the given networkInterface
public ChannelFuture
block(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress sourceToBlock, ChannelPromise promise)

Implements io.netty.channel.socket.DatagramChannel.block.

Block the given sourceToBlock address for the given multicastAddress on the given networkInterface
public ChannelFuture
block(InetAddress multicastAddress, InetAddress sourceToBlock)

Implements io.netty.channel.socket.DatagramChannel.block.

Block the given sourceToBlock address for the given multicastAddress
public ChannelFuture
block(InetAddress multicastAddress, InetAddress sourceToBlock, ChannelPromise promise)

Implements io.netty.channel.socket.DatagramChannel.block.

Block the given sourceToBlock address for the given multicastAddress
private static void
private static void
pack-priv void
protected boolean
public DatagramChannelConfig
config()

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

Returns the configuration of this channel.
protected boolean
continueOnWriteError()

Overrides io.netty.channel.nio.AbstractNioMessageChannel.continueOnWriteError.

Returns true if we should continue the write loop on a write error.
protected boolean
protected void
doBind(SocketAddress localAddress)

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

Bind the Channel to the SocketAddress
private void
doBind0(SocketAddress localAddress)

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 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.
public boolean
isConnected()

Implements io.netty.channel.socket.DatagramChannel.isConnected.

Return true if the DatagramChannel is connected to the remote peer.
private static boolean
isSingleDirectBuffer(ByteBuf buf)

Checks if the specified buffer is a direct buffer and is composed of a single NIO buffer.

protected DatagramChannel
public ChannelFuture
joinGroup(InetAddress multicastAddress)

Implements io.netty.channel.socket.DatagramChannel.joinGroup.

Joins a multicast group and notifies the ChannelFuture once the operation completes.
public ChannelFuture
joinGroup(InetAddress multicastAddress, ChannelPromise promise)

Implements io.netty.channel.socket.DatagramChannel.joinGroup.

Joins a multicast group and notifies the ChannelFuture once the operation completes.
public ChannelFuture
joinGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface)

Implements io.netty.channel.socket.DatagramChannel.joinGroup.

Joins the specified multicast group at the specified interface and notifies the ChannelFuture once the operation completes.
public ChannelFuture
joinGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface, ChannelPromise promise)

Implements io.netty.channel.socket.DatagramChannel.joinGroup.

Joins the specified multicast group at the specified interface and notifies the ChannelFuture once the operation completes.
public ChannelFuture
joinGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source)

Implements io.netty.channel.socket.DatagramChannel.joinGroup.

Joins the specified multicast group at the specified interface and notifies the ChannelFuture once the operation completes.
public ChannelFuture
joinGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise)

Implements io.netty.channel.socket.DatagramChannel.joinGroup.

Joins the specified multicast group at the specified interface and notifies the ChannelFuture once the operation completes.
public ChannelFuture
leaveGroup(InetAddress multicastAddress)

Implements io.netty.channel.socket.DatagramChannel.leaveGroup.

Leaves a multicast group and notifies the ChannelFuture once the operation completes.
public ChannelFuture
leaveGroup(InetAddress multicastAddress, ChannelPromise promise)

Implements io.netty.channel.socket.DatagramChannel.leaveGroup.

Leaves a multicast group and notifies the ChannelFuture once the operation completes.
public ChannelFuture
leaveGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface)

Implements io.netty.channel.socket.DatagramChannel.leaveGroup.

Leaves a multicast group on a specified local interface and notifies the ChannelFuture once the operation completes.
public ChannelFuture
leaveGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface, ChannelPromise promise)

Implements io.netty.channel.socket.DatagramChannel.leaveGroup.

Leaves a multicast group on a specified local interface and notifies the ChannelFuture once the operation completes.
public ChannelFuture
leaveGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source)

Implements io.netty.channel.socket.DatagramChannel.leaveGroup.

Leave the specified multicast group at the specified interface using the specified source and notifies the ChannelFuture once the operation completes.
public ChannelFuture
leaveGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise)

Implements io.netty.channel.socket.DatagramChannel.leaveGroup.

Leave the specified multicast group at the specified interface using the specified source and notifies the ChannelFuture once the operation completes.
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 DatagramChannel
private static DatagramChannel
public InetSocketAddress
protected SocketAddress
remoteAddress0()

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

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

Field Detail

configback to summary
private final DatagramChannelConfig config
DEFAULT_SELECTOR_PROVIDERback to summary
private static final SelectorProvider DEFAULT_SELECTOR_PROVIDER
EXPECTED_TYPESback to summary
private static final String EXPECTED_TYPES
membershipsback to summary
private Map<InetAddress, List<MembershipKey>> memberships
METADATAback to summary
private static final ChannelMetadata METADATA

Constructor Detail

NioDatagramChannelback to summary
public NioDatagramChannel()

Create a new instance which will use the Operation Systems default InternetProtocolFamily.

NioDatagramChannelback to summary
public NioDatagramChannel(SelectorProvider provider)

Create a new instance using the given SelectorProvider which will use the Operation Systems default InternetProtocolFamily.

NioDatagramChannelback to summary
public NioDatagramChannel(InternetProtocolFamily ipFamily)

Create a new instance using the given InternetProtocolFamily. If null is used it will depend on the Operation Systems default which will be chosen.

NioDatagramChannelback to summary
public NioDatagramChannel(SelectorProvider provider, InternetProtocolFamily ipFamily)

Create a new instance using the given SelectorProvider and InternetProtocolFamily. If InternetProtocolFamily is null it will depend on the Operation Systems default which will be chosen.

NioDatagramChannelback to summary
public NioDatagramChannel(DatagramChannel socket)

Create a new instance from the given DatagramChannel.

Method Detail

blockback to summary
public ChannelFuture block(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress sourceToBlock)

Implements io.netty.channel.socket.DatagramChannel.block.

Block the given sourceToBlock address for the given multicastAddress on the given networkInterface

Annotations
@Override
blockback to summary
public ChannelFuture block(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress sourceToBlock, ChannelPromise promise)

Implements io.netty.channel.socket.DatagramChannel.block.

Block the given sourceToBlock address for the given multicastAddress on the given networkInterface

Annotations
@SuppressJava6Requirement
reason:Usage guarded by java version check
@Override
blockback to summary
public ChannelFuture block(InetAddress multicastAddress, InetAddress sourceToBlock)

Implements io.netty.channel.socket.DatagramChannel.block.

Block the given sourceToBlock address for the given multicastAddress

Annotations
@Override
blockback to summary
public ChannelFuture block(InetAddress multicastAddress, InetAddress sourceToBlock, ChannelPromise promise)

Implements io.netty.channel.socket.DatagramChannel.block.

Block the given sourceToBlock address for the given multicastAddress

Annotations
@Override
checkJavaVersionback to summary
private static void checkJavaVersion()
checkUnresolvedback to summary
private static void checkUnresolved(AddressedEnvelope<?, ?> envelope)
clearReadPending0back to summary
pack-priv void clearReadPending0()

Hides io.netty.channel.nio.AbstractNioChannel.clearReadPending0.

closeOnReadErrorback to summary
protected boolean closeOnReadError(Throwable cause)

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

Annotations
@Override
configback to summary
public DatagramChannelConfig config()

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

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

Returns the configuration of this channel.

Annotations
@Override
continueOnWriteErrorback to summary
protected boolean continueOnWriteError()

Overrides io.netty.channel.nio.AbstractNioMessageChannel.continueOnWriteError.

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

Returns true if we should continue the write loop on a write error.

Annotations
@Override
continueReadingback to summary
protected boolean continueReading(RecvByteBufAllocator.Handle allocHandle)

Overrides io.netty.channel.nio.AbstractNioMessageChannel.continueReading.

Deprecated

as a consequence of RecvByteBufAllocator.Handle being deprecated. See corresponding docs for further information.

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
@Override
doBind0back to summary
private void doBind0(SocketAddress localAddress) throws Exception
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 Object filterOutboundMessage(Object msg)

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
@SuppressWarnings:deprecation
isConnectedback to summary
public boolean isConnected()

Implements io.netty.channel.socket.DatagramChannel.isConnected.

Doc from io.netty.channel.socket.DatagramChannel.isConnected.

Return true if the DatagramChannel is connected to the remote peer.

Annotations
@Override
isSingleDirectBufferback to summary
private static boolean isSingleDirectBuffer(ByteBuf buf)

Checks if the specified buffer is a direct buffer and is composed of a single NIO buffer. (We check this because otherwise we need to make it a non-composite buffer.)

javaChannelback to summary
protected DatagramChannel javaChannel()

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

Annotations
@Override
joinGroupback to summary
public ChannelFuture joinGroup(InetAddress multicastAddress)

Implements io.netty.channel.socket.DatagramChannel.joinGroup.

Doc from io.netty.channel.socket.DatagramChannel.joinGroup.

Joins a multicast group and notifies the ChannelFuture once the operation completes.

Annotations
@Override
joinGroupback to summary
public ChannelFuture joinGroup(InetAddress multicastAddress, ChannelPromise promise)

Implements io.netty.channel.socket.DatagramChannel.joinGroup.

Doc from io.netty.channel.socket.DatagramChannel.joinGroup.

Joins a multicast group and notifies the ChannelFuture once the operation completes. The given ChannelFuture will be notified and also returned.

Annotations
@Override
joinGroupback to summary
public ChannelFuture joinGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface)

Implements io.netty.channel.socket.DatagramChannel.joinGroup.

Doc from io.netty.channel.socket.DatagramChannel.joinGroup.

Joins the specified multicast group at the specified interface and notifies the ChannelFuture once the operation completes.

Annotations
@Override
joinGroupback to summary
public ChannelFuture joinGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface, ChannelPromise promise)

Implements io.netty.channel.socket.DatagramChannel.joinGroup.

Doc from io.netty.channel.socket.DatagramChannel.joinGroup.

Joins the specified multicast group at the specified interface and notifies the ChannelFuture once the operation completes. The given ChannelFuture will be notified and also returned.

Annotations
@Override
joinGroupback to summary
public ChannelFuture joinGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source)

Implements io.netty.channel.socket.DatagramChannel.joinGroup.

Doc from io.netty.channel.socket.DatagramChannel.joinGroup.

Joins the specified multicast group at the specified interface and notifies the ChannelFuture once the operation completes.

Annotations
@Override
joinGroupback to summary
public ChannelFuture joinGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise)

Implements io.netty.channel.socket.DatagramChannel.joinGroup.

Doc from io.netty.channel.socket.DatagramChannel.joinGroup.

Joins the specified multicast group at the specified interface and notifies the ChannelFuture once the operation completes. The given ChannelFuture will be notified and also returned.

Annotations
@SuppressJava6Requirement
reason:Usage guarded by java version check
@Override
leaveGroupback to summary
public ChannelFuture leaveGroup(InetAddress multicastAddress)

Implements io.netty.channel.socket.DatagramChannel.leaveGroup.

Doc from io.netty.channel.socket.DatagramChannel.leaveGroup.

Leaves a multicast group and notifies the ChannelFuture once the operation completes.

Annotations
@Override
leaveGroupback to summary
public ChannelFuture leaveGroup(InetAddress multicastAddress, ChannelPromise promise)

Implements io.netty.channel.socket.DatagramChannel.leaveGroup.

Doc from io.netty.channel.socket.DatagramChannel.leaveGroup.

Leaves a multicast group and notifies the ChannelFuture once the operation completes. The given ChannelFuture will be notified and also returned.

Annotations
@Override
leaveGroupback to summary
public ChannelFuture leaveGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface)

Implements io.netty.channel.socket.DatagramChannel.leaveGroup.

Doc from io.netty.channel.socket.DatagramChannel.leaveGroup.

Leaves a multicast group on a specified local interface and notifies the ChannelFuture once the operation completes.

Annotations
@Override
leaveGroupback to summary
public ChannelFuture leaveGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface, ChannelPromise promise)

Implements io.netty.channel.socket.DatagramChannel.leaveGroup.

Doc from io.netty.channel.socket.DatagramChannel.leaveGroup.

Leaves a multicast group on a specified local interface and notifies the ChannelFuture once the operation completes. The given ChannelFuture will be notified and also returned.

Annotations
@Override
leaveGroupback to summary
public ChannelFuture leaveGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source)

Implements io.netty.channel.socket.DatagramChannel.leaveGroup.

Doc from io.netty.channel.socket.DatagramChannel.leaveGroup.

Leave the specified multicast group at the specified interface using the specified source and notifies the ChannelFuture once the operation completes.

Annotations
@Override
leaveGroupback to summary
public ChannelFuture leaveGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise)

Implements io.netty.channel.socket.DatagramChannel.leaveGroup.

Doc from io.netty.channel.socket.DatagramChannel.leaveGroup.

Leave the specified multicast group at the specified interface using the specified source and notifies the ChannelFuture once the operation completes. The given ChannelFuture will be notified and also returned.

Annotations
@SuppressJava6Requirement
reason:Usage guarded by java version check
@Override
localAddressback to summary
public InetSocketAddress localAddress()

Overrides io.netty.channel.AbstractChannel.localAddress.

Implements io.netty.channel.socket.DatagramChannel.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
newSocketback to summary
private static DatagramChannel newSocket(SelectorProvider provider)
newSocketback to summary
private static DatagramChannel newSocket(SelectorProvider provider, InternetProtocolFamily ipFamily)
Annotations
@SuppressJava6Requirement
reason:Usage guarded by java version check
remoteAddressback to summary
public InetSocketAddress remoteAddress()

Overrides io.netty.channel.AbstractChannel.remoteAddress.

Implements io.netty.channel.socket.DatagramChannel.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
setReadPendingback to summary
protected void setReadPending(boolean readPending)

Overrides io.netty.channel.nio.AbstractNioChannel.setReadPending.

Deprecated

Annotations
@Override
@Deprecated