public final class NioDatagramAcceptor extends AbstractIoAcceptor implements DatagramAcceptor, IoProcessor<NioSession>
IoAcceptor for datagram transport (UDP/IP).AbstractIoAcceptor.AcceptorOperationFutureAbstractIoService.ServiceOperationFuturebindLockdisposalLock, sessionConfig| Constructor and Description |
|---|
NioDatagramAcceptor()
Creates a new instance.
|
NioDatagramAcceptor(Executor executor)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(NioSession session)
Adds the specified
session to the I/O processor so that
the I/O processor starts to perform any I/O operations related
with the session. |
protected Set<SocketAddress> |
bindInternal(List<? extends SocketAddress> localAddresses)
Starts the acceptor, and register the given addresses
|
protected void |
close(DatagramChannel handle) |
protected void |
destroy() |
protected void |
dispose0()
Implement this method to release any acquired resources.
|
void |
flush(NioSession session)
Flushes the internal write request queue of the specified
session. |
InetSocketAddress |
getDefaultLocalAddress()
Returns the default local address to bind when no argument is specified
in
IoAcceptor.bind() method. |
InetSocketAddress |
getLocalAddress()
Returns the local address which is bound currently.
|
DatagramSessionConfig |
getSessionConfig()
Returns the default Datagram configuration of the new
IoSessions
created by this service. |
IoSessionRecycler |
getSessionRecycler()
Returns the
IoSessionRecycler for this service. |
TransportMetadata |
getTransportMetadata()
Returns the
TransportMetadata that this service runs on. |
protected void |
init() |
protected boolean |
isReadable(DatagramChannel handle) |
protected boolean |
isWritable(DatagramChannel handle) |
protected SocketAddress |
localAddress(DatagramChannel handle) |
protected NioSession |
newSession(IoProcessor<NioSession> processor,
DatagramChannel handle,
SocketAddress remoteAddress) |
IoSession |
newSession(SocketAddress remoteAddress,
SocketAddress localAddress)
(Optional) Returns an
IoSession that is bound to the specified
localAddress and the specified remoteAddress which
reuses the local address that is already bound by this service. |
protected DatagramChannel |
open(SocketAddress localAddress) |
protected SocketAddress |
receive(DatagramChannel handle,
IoBuffer buffer) |
void |
remove(NioSession session)
Removes and closes the specified
session from the I/O
processor so that the I/O processor closes the connection
associated with the session and releases any other related
resources. |
protected int |
select() |
protected int |
select(long timeout) |
protected Set<SelectionKey> |
selectedHandles() |
protected int |
send(NioSession session,
IoBuffer buffer,
SocketAddress remoteAddress) |
void |
setDefaultLocalAddress(InetSocketAddress localAddress)
Sets the default local InetSocketAddress to bind when no argument is specified in
IoAcceptor.bind() method. |
protected void |
setInterestedInWrite(NioSession session,
boolean isInterested) |
void |
setSessionRecycler(IoSessionRecycler sessionRecycler)
Sets the
IoSessionRecycler for this service. |
protected void |
unbind0(List<? extends SocketAddress> localAddresses)
Implement this method to perform the actual unbind operation.
|
void |
updateTrafficControl(NioSession session)
Controls the traffic of the specified
session depending of the
IoSession.isReadSuspended() and IoSession.isWriteSuspended()
flags |
protected void |
wakeup() |
void |
write(NioSession session,
WriteRequest writeRequest)
Writes the WriteRequest for the specified
session. |
bind, bind, bind, bind, bind, getDefaultLocalAddresses, getLocalAddresses, isCloseOnDeactivation, setCloseOnDeactivation, setDefaultLocalAddress, setDefaultLocalAddresses, setDefaultLocalAddresses, setDefaultLocalAddresses, toString, unbind, unbind, unbind, unbindaddListener, broadcast, dispose, dispose, executeWorker, executeWorker, finishSessionInitialization0, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getListeners, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, initSession, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactoryclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitbind, bind, bind, bind, bind, getDefaultLocalAddresses, getLocalAddresses, isCloseOnDeactivation, setCloseOnDeactivation, setDefaultLocalAddress, setDefaultLocalAddresses, setDefaultLocalAddresses, setDefaultLocalAddresses, unbind, unbind, unbind, unbindaddListener, broadcast, dispose, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactorydispose, isDisposed, isDisposingpublic NioDatagramAcceptor()
public NioDatagramAcceptor(Executor executor)
public void add(NioSession session)
session to the I/O processor so that
the I/O processor starts to perform any I/O operations related
with the session.add in interface IoProcessor<NioSession>session - The added sessionprotected final Set<SocketAddress> bindInternal(List<? extends SocketAddress> localAddresses) throws Exception
bindInternal in class AbstractIoAcceptorSet of the local addresses which is bound actuallyExceptionprotected void close(DatagramChannel handle) throws Exception
Exceptionprotected void dispose0()
throws Exception
AbstractIoService.dispose().dispose0 in class AbstractIoServiceExceptionpublic void flush(NioSession session)
session.flush in interface IoProcessor<NioSession>session - The session we want the message to be writtenpublic InetSocketAddress getDefaultLocalAddress()
AbstractIoAcceptorIoAcceptor.bind() method. Please note that the default will not be
used if any local address is specified. If more than one address are
set, only one of them will be returned, but it's not necessarily the
firstly specified address in IoAcceptor.setDefaultLocalAddresses(List).getDefaultLocalAddress in interface IoAcceptorgetDefaultLocalAddress in interface DatagramAcceptorgetDefaultLocalAddress in class AbstractIoAcceptorpublic InetSocketAddress getLocalAddress()
AbstractIoAcceptorgetLocalAddress in interface IoAcceptorgetLocalAddress in interface DatagramAcceptorgetLocalAddress in class AbstractIoAcceptorpublic DatagramSessionConfig getSessionConfig()
IoSessions
created by this service.getSessionConfig in interface IoServicegetSessionConfig in interface DatagramAcceptorpublic final IoSessionRecycler getSessionRecycler()
DatagramAcceptorIoSessionRecycler for this service.getSessionRecycler in interface DatagramAcceptorpublic TransportMetadata getTransportMetadata()
IoServiceTransportMetadata that this service runs on.getTransportMetadata in interface IoServiceprotected boolean isReadable(DatagramChannel handle)
protected boolean isWritable(DatagramChannel handle)
protected SocketAddress localAddress(DatagramChannel handle) throws Exception
Exceptionprotected NioSession newSession(IoProcessor<NioSession> processor, DatagramChannel handle, SocketAddress remoteAddress)
public final IoSession newSession(SocketAddress remoteAddress, SocketAddress localAddress)
IoSession that is bound to the specified
localAddress and the specified remoteAddress which
reuses the local address that is already bound by this service.
This operation is optional. Please throw UnsupportedOperationException
if the transport type doesn't support this operation. This operation is
usually implemented for connectionless transport types.
newSession in interface IoAcceptorprotected DatagramChannel open(SocketAddress localAddress) throws Exception
Exceptionprotected SocketAddress receive(DatagramChannel handle, IoBuffer buffer) throws Exception
Exceptionpublic void remove(NioSession session)
session from the I/O
processor so that the I/O processor closes the connection
associated with the session and releases any other related
resources.remove in interface IoProcessor<NioSession>protected Set<SelectionKey> selectedHandles()
protected int send(NioSession session, IoBuffer buffer, SocketAddress remoteAddress) throws Exception
Exceptionpublic void setDefaultLocalAddress(InetSocketAddress localAddress)
DatagramAcceptorIoAcceptor.bind() method. Please note that the default will not be used
if any local InetSocketAddress is specified.
This method overrides the IoAcceptor.setDefaultLocalAddress(java.net.SocketAddress) method.setDefaultLocalAddress in interface DatagramAcceptorprotected void setInterestedInWrite(NioSession session, boolean isInterested) throws Exception
Exceptionpublic final void setSessionRecycler(IoSessionRecycler sessionRecycler)
DatagramAcceptorIoSessionRecycler for this service.setSessionRecycler in interface DatagramAcceptorsessionRecycler - null to use the default recyclerprotected final void unbind0(List<? extends SocketAddress> localAddresses) throws Exception
unbind0 in class AbstractIoAcceptorExceptionpublic void updateTrafficControl(NioSession session)
session depending of the
IoSession.isReadSuspended() and IoSession.isWriteSuspended()
flagsupdateTrafficControl in interface IoProcessor<NioSession>protected void wakeup()
public void write(NioSession session, WriteRequest writeRequest)
session.write in interface IoProcessor<NioSession>session - The session we want the message to be writtenwriteRequest - the WriteRequest to writeCopyright © 2004–2017 Apache MINA Project. All rights reserved.