public final class NioDatagramChannel extends AbstractNioMessageChannel implements DatagramChannel
Channel that sends and receives an
AddressedEnvelope.AddressedEnvelope,
DatagramPacketAbstractNioChannel.AbstractNioUnsafe, AbstractNioChannel.NioUnsafeAbstractChannel.AbstractUnsafeChannel.UnsafereadInterestOp| Constructor and Description |
|---|
NioDatagramChannel()
Create a new instance which will use the Operation Systems default
InternetProtocolFamily. |
NioDatagramChannel(DatagramChannel socket)
Create a new instance from the given
DatagramChannel. |
NioDatagramChannel(InternetProtocolFamily ipFamily)
Create a new instance using the given
InternetProtocolFamily. |
| Modifier and Type | Method and Description |
|---|---|
io.netty.buffer.ByteBufAllocator |
alloc()
Return the assigned
ByteBufAllocator which will be used to allocate ByteBufs. |
ChannelFuture |
bind(SocketAddress localAddress)
Request to bind to the given
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error. |
ChannelFuture |
bind(SocketAddress localAddress,
ChannelPromise promise)
Request to bind to the given
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error. |
ChannelFuture |
block(InetAddress multicastAddress,
InetAddress sourceToBlock)
Block the given sourceToBlock address for the given multicastAddress
|
ChannelFuture |
block(InetAddress multicastAddress,
InetAddress sourceToBlock,
ChannelPromise promise)
Block the given sourceToBlock address for the given multicastAddress
|
ChannelFuture |
block(InetAddress multicastAddress,
NetworkInterface networkInterface,
InetAddress sourceToBlock)
Block the given sourceToBlock address for the given multicastAddress on the given networkInterface
|
ChannelFuture |
block(InetAddress multicastAddress,
NetworkInterface networkInterface,
InetAddress sourceToBlock,
ChannelPromise promise)
Block the given sourceToBlock address for the given multicastAddress on the given networkInterface
|
ChannelFuture |
close()
Request to close this ChannelOutboundInvoker and notify the
ChannelFuture once the operation completes,
either because the operation was successful or because of
an error. |
ChannelFuture |
close(ChannelPromise promise)
Request to close this ChannelOutboundInvoker and notify the
ChannelFuture once the operation completes,
either because the operation was successful or because of
an error. |
DatagramChannelConfig |
config()
Returns the configuration of this channel.
|
ChannelFuture |
connect(SocketAddress remoteAddress)
Request to connect to the given
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error. |
ChannelFuture |
connect(SocketAddress remoteAddress,
ChannelPromise promise)
Request to connect to the given
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error. |
ChannelFuture |
connect(SocketAddress remoteAddress,
SocketAddress localAddress)
Request to connect to the given
SocketAddress while bind to the localAddress and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error. |
ChannelFuture |
connect(SocketAddress remoteAddress,
SocketAddress localAddress,
ChannelPromise promise)
Request to connect to the given
SocketAddress while bind to the localAddress and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error. |
ChannelFuture |
deregister()
Request to deregister this ChannelOutboundInvoker from the previous assigned
EventExecutor and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error. |
ChannelFuture |
deregister(ChannelPromise promise)
Request to deregister this ChannelOutboundInvoker from the previous assigned
EventExecutor and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error. |
ChannelFuture |
disconnect()
Request to disconnect from the remote peer and notify the
ChannelFuture once the operation completes,
either because the operation was successful or because of an error. |
ChannelFuture |
disconnect(ChannelPromise promise)
Request to disconnect from the remote peer and notify the
ChannelFuture once the operation completes,
either because the operation was successful or because of an error. |
protected void |
doBind(SocketAddress localAddress)
Bind the
Channel to the SocketAddress |
protected void |
doClose()
Close the
Channel |
protected boolean |
doConnect(SocketAddress remoteAddress,
SocketAddress localAddress)
Connect to the remote peer
|
protected void |
doDisconnect()
Disconnect this
Channel from its remote peer |
protected void |
doFinishConnect()
Finish the connect
|
protected int |
doReadMessages(List<Object> buf)
Read messages into the given array and return the amount which was read.
|
protected boolean |
doWriteMessage(Object msg)
Write a message to the underlying
Channel. |
boolean |
isActive()
Return
true if the Channel is active and so connected. |
boolean |
isConnected()
Return
true if the DatagramChannel is connected to the remote peer. |
protected DatagramChannel |
javaChannel() |
ChannelFuture |
joinGroup(InetAddress multicastAddress)
Joins a multicast group and notifies the
ChannelFuture once the operation completes. |
ChannelFuture |
joinGroup(InetAddress multicastAddress,
ChannelPromise promise)
Joins a multicast group and notifies the
ChannelFuture once the operation completes. |
ChannelFuture |
joinGroup(InetAddress multicastAddress,
NetworkInterface networkInterface,
InetAddress source)
Joins the specified multicast group at the specified interface and notifies the
ChannelFuture
once the operation completes. |
ChannelFuture |
joinGroup(InetAddress multicastAddress,
NetworkInterface networkInterface,
InetAddress source,
ChannelPromise promise)
Joins the specified multicast group at the specified interface and notifies the
ChannelFuture
once the operation completes. |
ChannelFuture |
joinGroup(InetSocketAddress multicastAddress,
NetworkInterface networkInterface)
Joins the specified multicast group at the specified interface and notifies the
ChannelFuture
once the operation completes. |
ChannelFuture |
joinGroup(InetSocketAddress multicastAddress,
NetworkInterface networkInterface,
ChannelPromise promise)
Joins the specified multicast group at the specified interface and notifies the
ChannelFuture
once the operation completes. |
ChannelFuture |
leaveGroup(InetAddress multicastAddress)
Leaves a multicast group and notifies the
ChannelFuture once the operation completes. |
ChannelFuture |
leaveGroup(InetAddress multicastAddress,
ChannelPromise promise)
Leaves a multicast group and notifies the
ChannelFuture once the operation completes. |
ChannelFuture |
leaveGroup(InetAddress multicastAddress,
NetworkInterface networkInterface,
InetAddress source)
Leave the specified multicast group at the specified interface using the specified source and notifies
the
ChannelFuture once the operation completes. |
ChannelFuture |
leaveGroup(InetAddress multicastAddress,
NetworkInterface networkInterface,
InetAddress source,
ChannelPromise promise)
Leave the specified multicast group at the specified interface using the specified source and notifies
the
ChannelFuture once the operation completes. |
ChannelFuture |
leaveGroup(InetSocketAddress multicastAddress,
NetworkInterface networkInterface)
Leaves a multicast group on a specified local interface and notifies the
ChannelFuture once the
operation completes. |
ChannelFuture |
leaveGroup(InetSocketAddress multicastAddress,
NetworkInterface networkInterface,
ChannelPromise promise)
Leaves a multicast group on a specified local interface and notifies the
ChannelFuture once the
operation completes. |
InetSocketAddress |
localAddress()
Returns the local address where this channel is bound to.
|
protected SocketAddress |
localAddress0()
Returns the
SocketAddress which is bound locally. |
ChannelMetadata |
metadata()
|
ChannelFuture |
newFailedFuture(Throwable cause)
Create a new
ChannelFuture which is marked as failed already. |
ChannelProgressivePromise |
newProgressivePromise()
Return an new
ChannelProgressivePromise |
ChannelPromise |
newPromise()
Return a new
ChannelPromise. |
ChannelFuture |
newSucceededFuture()
Create a new
ChannelFuture which is marked as succeeded already. |
ChannelPipeline |
pipeline()
Return the assigned
ChannelPipeline |
InetSocketAddress |
remoteAddress()
Returns the remote address where this channel is connected to.
|
protected SocketAddress |
remoteAddress0()
Return the
SocketAddress which the Channel is connected to. |
ChannelPromise |
voidPromise()
Return a special ChannelPromise which can be reused for different operations.
|
ChannelFuture |
write(Object msg)
Request to write a message via this ChannelOutboundInvoker through the
ChannelPipeline. |
ChannelFuture |
write(Object msg,
ChannelPromise promise)
Request to write a message via this ChannelOutboundInvoker through the
ChannelPipeline. |
ChannelFuture |
writeAndFlush(Object msg)
Shortcut for call
write(Object) and flush(). |
ChannelFuture |
writeAndFlush(Object msg,
ChannelPromise promise)
Shortcut for call
write(Object, ChannelPromise) and flush(). |
doWrite, newUnsafedoBeginRead, doDeregister, doRegister, eventLoop, isCompatible, isInputShutdown, isOpen, selectionKey, unsafealloc, bind, bind, calculateMessageSize, checkEOF, close, close, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, doPreClose, equals, flush, hashCode, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, parent, pipeline, read, toString, voidPromise, write, write, writeAndFlush, writeAndFlushclone, finalize, getClass, notify, notifyAll, wait, wait, waitcloseFuture, eventLoop, flush, isOpen, isRegistered, isWritable, parent, read, unsafecompareTopublic NioDatagramChannel()
InternetProtocolFamily.public NioDatagramChannel(InternetProtocolFamily ipFamily)
InternetProtocolFamily. If null is used it will depend
on the Operation Systems default which will be chosen.public NioDatagramChannel(DatagramChannel socket)
DatagramChannel.public ChannelMetadata metadata()
Channelpublic DatagramChannelConfig config()
Channelconfig in interface Channelconfig in interface DatagramChannelpublic boolean isActive()
Channeltrue if the Channel is active and so connected.public boolean isConnected()
DatagramChanneltrue if the DatagramChannel is connected to the remote peer.isConnected in interface DatagramChannelprotected DatagramChannel javaChannel()
javaChannel in class AbstractNioChannelprotected SocketAddress localAddress0()
AbstractChannelSocketAddress which is bound locally.localAddress0 in class AbstractChannelprotected SocketAddress remoteAddress0()
AbstractChannelSocketAddress which the Channel is connected to.remoteAddress0 in class AbstractChannelprotected void doBind(SocketAddress localAddress) throws Exception
AbstractChannelChannel to the SocketAddressdoBind in class AbstractChannelExceptionprotected boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception
AbstractNioChanneldoConnect in class AbstractNioChannelExceptionprotected void doFinishConnect()
throws Exception
AbstractNioChanneldoFinishConnect in class AbstractNioChannelExceptionprotected void doDisconnect()
throws Exception
AbstractChannelChannel from its remote peerdoDisconnect in class AbstractChannelExceptionprotected void doClose()
throws Exception
AbstractChannelChanneldoClose in class AbstractChannelExceptionprotected int doReadMessages(List<Object> buf) throws Exception
AbstractNioMessageChanneldoReadMessages in class AbstractNioMessageChannelExceptionprotected boolean doWriteMessage(Object msg) throws Exception
AbstractNioMessageChannelChannel.doWriteMessage in class AbstractNioMessageChanneltrue if and only if the message has been writtenExceptionpublic InetSocketAddress localAddress()
ChannelSocketAddress is supposed to be down-cast into more concrete
type such as InetSocketAddress to retrieve the detailed
information.localAddress in interface ChannellocalAddress in interface DatagramChannellocalAddress in class AbstractChannelnull if this channel is not bound.public InetSocketAddress remoteAddress()
ChannelSocketAddress is supposed to be down-cast into more
concrete type such as InetSocketAddress to retrieve the detailed
information.remoteAddress in interface ChannelremoteAddress in interface DatagramChannelremoteAddress in class AbstractChannelnull 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 DefaultAddressedEnvelope.recipient() to determine
the origination of the received message as this method will
return null.public ChannelFuture joinGroup(InetAddress multicastAddress)
DatagramChannelChannelFuture once the operation completes.joinGroup in interface DatagramChannelpublic ChannelFuture joinGroup(InetAddress multicastAddress, ChannelPromise promise)
DatagramChannelChannelFuture once the operation completes.
The given ChannelFuture will be notified and also returned.joinGroup in interface DatagramChannelpublic ChannelFuture joinGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface)
DatagramChannelChannelFuture
once the operation completes.joinGroup in interface DatagramChannelpublic ChannelFuture joinGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface, ChannelPromise promise)
DatagramChannelChannelFuture
once the operation completes.
The given ChannelFuture will be notified and also returned.joinGroup in interface DatagramChannelpublic ChannelFuture joinGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source)
DatagramChannelChannelFuture
once the operation completes.joinGroup in interface DatagramChannelpublic ChannelFuture joinGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise)
DatagramChannelChannelFuture
once the operation completes.
The given ChannelFuture will be notified and also returned.joinGroup in interface DatagramChannelpublic ChannelFuture leaveGroup(InetAddress multicastAddress)
DatagramChannelChannelFuture once the operation completes.leaveGroup in interface DatagramChannelpublic ChannelFuture leaveGroup(InetAddress multicastAddress, ChannelPromise promise)
DatagramChannelChannelFuture once the operation completes.
The given ChannelFuture will be notified and also returned.leaveGroup in interface DatagramChannelpublic ChannelFuture leaveGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface)
DatagramChannelChannelFuture once the
operation completes.leaveGroup in interface DatagramChannelpublic ChannelFuture leaveGroup(InetSocketAddress multicastAddress, NetworkInterface networkInterface, ChannelPromise promise)
DatagramChannelChannelFuture once the
operation completes.
The given ChannelFuture will be notified and also returned.leaveGroup in interface DatagramChannelpublic ChannelFuture leaveGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source)
DatagramChannelChannelFuture once the operation completes.leaveGroup in interface DatagramChannelpublic ChannelFuture leaveGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source, ChannelPromise promise)
DatagramChannelChannelFuture once the operation completes.
The given ChannelFuture will be notified and also returned.leaveGroup in interface DatagramChannelpublic ChannelFuture block(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress sourceToBlock)
block in interface DatagramChannelpublic ChannelFuture block(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress sourceToBlock, ChannelPromise promise)
block in interface DatagramChannelpublic ChannelFuture block(InetAddress multicastAddress, InetAddress sourceToBlock)
block in interface DatagramChannelpublic ChannelFuture block(InetAddress multicastAddress, InetAddress sourceToBlock, ChannelPromise promise)
block in interface DatagramChannelpublic ChannelFuture bind(SocketAddress localAddress)
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error.
This will result in having the
ChannelOutboundHandler.bind(ChannelHandlerContext, SocketAddress, ChannelPromise) method
called of the next ChannelOutboundHandler contained in the ChannelPipeline of the
Channel.
public ChannelFuture connect(SocketAddress remoteAddress)
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error.
If the connection fails because of a connection timeout, the ChannelFuture will get failed with
a ConnectTimeoutException. If it fails because of connection refused a ConnectException
will be used.
This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the next ChannelOutboundHandler contained in the ChannelPipeline of the
Channel.
public ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress)
SocketAddress while bind to the localAddress and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error.
This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the next ChannelOutboundHandler contained in the ChannelPipeline of the
Channel.
public ChannelFuture disconnect()
ChannelFuture once the operation completes,
either because the operation was successful or because of an error.
This will result in having the
ChannelOutboundHandler.disconnect(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelOutboundHandler contained in the ChannelPipeline of the
Channel.
public ChannelFuture close()
ChannelFuture once the operation completes,
either because the operation was successful or because of
an error.
After it is closed it is not possible to reuse it again.
This will result in having the
ChannelOutboundHandler.close(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelOutboundHandler contained in the ChannelPipeline of the
Channel.
public ChannelFuture deregister()
EventExecutor and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error.
This will result in having the
ChannelOutboundHandler.deregister(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelOutboundHandler contained in the ChannelPipeline of the
Channel.
public ChannelFuture bind(SocketAddress localAddress, ChannelPromise promise)
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error.
The given ChannelPromise will be notified.
This will result in having the
ChannelOutboundHandler.bind(ChannelHandlerContext, SocketAddress, ChannelPromise) method
called of the next ChannelOutboundHandler contained in the ChannelPipeline of the
Channel.
public ChannelFuture connect(SocketAddress remoteAddress, ChannelPromise promise)
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error.
The given ChannelFuture will be notified.
If the connection fails because of a connection timeout, the ChannelFuture will get failed with
a ConnectTimeoutException. If it fails because of connection refused a ConnectException
will be used.
This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the next ChannelOutboundHandler contained in the ChannelPipeline of the
Channel.
public ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise)
SocketAddress while bind to the localAddress and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error.
The given ChannelPromise will be notified and also returned.
This will result in having the
ChannelOutboundHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the next ChannelOutboundHandler contained in the ChannelPipeline of the
Channel.
public ChannelFuture disconnect(ChannelPromise promise)
ChannelFuture once the operation completes,
either because the operation was successful or because of an error.
The given ChannelPromise will be notified.
This will result in having the
ChannelOutboundHandler.disconnect(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelOutboundHandler contained in the ChannelPipeline of the
Channel.
public ChannelFuture close(ChannelPromise promise)
ChannelFuture once the operation completes,
either because the operation was successful or because of
an error.
After it is closed it is not possible to reuse it again.
The given ChannelPromise will be notified.
This will result in having the
ChannelOutboundHandler.close(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelOutboundHandler contained in the ChannelPipeline of the
Channel.
public ChannelFuture deregister(ChannelPromise promise)
EventExecutor and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error.
The given ChannelPromise will be notified.
This will result in having the
ChannelOutboundHandler.deregister(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelOutboundHandler contained in the ChannelPipeline of the
Channel.
public ChannelFuture write(Object msg)
ChannelPipeline.
This method will not request to actual flush, so be sure to call flush()
once you want to request to flush all pending data to the actual transport.public ChannelFuture write(Object msg, ChannelPromise promise)
ChannelPipeline.
This method will not request to actual flush, so be sure to call flush()
once you want to request to flush all pending data to the actual transport.public ChannelFuture writeAndFlush(Object msg, ChannelPromise promise)
write(Object, ChannelPromise) and flush().public ChannelFuture writeAndFlush(Object msg)
write(Object) and flush().public ChannelPipeline pipeline()
ChannelPipelinepublic io.netty.buffer.ByteBufAllocator alloc()
ByteBufAllocator which will be used to allocate ByteBufs.public ChannelPromise newPromise()
ChannelPromise.public ChannelProgressivePromise newProgressivePromise()
ChannelProgressivePromisepublic ChannelFuture newSucceededFuture()
ChannelFuture which is marked as succeeded already. So Future.isSuccess()
will return true. All FutureListener added to it will be notified directly. Also
every call of blocking methods will just return without blocking.public ChannelFuture newFailedFuture(Throwable cause)
ChannelFuture which is marked as failed already. So Future.isSuccess()
will return false. All FutureListener added to it will be notified directly. Also
every call of blocking methods will just return without blocking.public ChannelPromise voidPromise()
It's only supported to use
it for ChannelOutboundInvoker.write(Object, ChannelPromise).
Be aware that the returned ChannelPromise will not support most operations and should only be used
if you want to save an object allocation for every write operation. You will not be able to detect if the
operation was complete, only if it failed as the implementation will call
ChannelPipeline.fireExceptionCaught(Throwable) in this case.
Copyright © 2008–2013 The Netty Project. All rights reserved.