public final class NioDatagramAcceptor extends AbstractIoAcceptor implements DatagramAcceptor, IoProcessor<NioSession>
IoAcceptor
for datagram transport (UDP/IP).AbstractIoAcceptor.AcceptorOperationFuture
AbstractIoService.ServiceOperationFuture
bindLock
disposalLock, sessionConfig
构造器和说明 |
---|
NioDatagramAcceptor()
Creates a new instance.
|
NioDatagramAcceptor(java.util.concurrent.Executor executor)
Creates a new instance.
|
限定符和类型 | 方法和说明 |
---|---|
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 java.util.Set<java.net.SocketAddress> |
bindInternal(java.util.List<? extends java.net.SocketAddress> localAddresses)
Starts the acceptor, and register the given addresses
|
protected void |
close(java.nio.channels.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 . |
java.net.InetSocketAddress |
getDefaultLocalAddress()
Returns the default local address to bind when no argument is specified
in
IoAcceptor.bind() method. |
java.net.InetSocketAddress |
getLocalAddress()
Returns the local address which is bound currently.
|
DatagramSessionConfig |
getSessionConfig() |
IoSessionRecycler |
getSessionRecycler() |
TransportMetadata |
getTransportMetadata() |
protected void |
init() |
protected boolean |
isReadable(java.nio.channels.DatagramChannel handle) |
protected boolean |
isWritable(java.nio.channels.DatagramChannel handle) |
protected java.net.SocketAddress |
localAddress(java.nio.channels.DatagramChannel handle) |
protected NioSession |
newSession(IoProcessor<NioSession> processor,
java.nio.channels.DatagramChannel handle,
java.net.SocketAddress remoteAddress) |
IoSession |
newSession(java.net.SocketAddress remoteAddress,
java.net.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 java.nio.channels.DatagramChannel |
open(java.net.SocketAddress localAddress) |
protected java.net.SocketAddress |
receive(java.nio.channels.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 java.util.Set<java.nio.channels.SelectionKey> |
selectedHandles() |
protected int |
send(NioSession session,
IoBuffer buffer,
java.net.SocketAddress remoteAddress) |
void |
setDefaultLocalAddress(java.net.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(java.util.List<? extends java.net.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, unbind
addListener, broadcast, dispose, dispose, executeWorker, executeWorker, finishSessionInitialization0, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getListeners, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, initSession, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
bind, bind, bind, bind, bind, getDefaultLocalAddresses, getLocalAddresses, isCloseOnDeactivation, setCloseOnDeactivation, setDefaultLocalAddress, setDefaultLocalAddresses, setDefaultLocalAddresses, setDefaultLocalAddresses, unbind, unbind, unbind, unbind
addListener, broadcast, dispose, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory
dispose, isDisposed, isDisposing
public NioDatagramAcceptor()
public NioDatagramAcceptor(java.util.concurrent.Executor executor)
executor
- The executor to useprotected void init() throws java.lang.Exception
java.lang.Exception
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
在接口中 IoProcessor<NioSession>
session
- The added sessionprotected final java.util.Set<java.net.SocketAddress> bindInternal(java.util.List<? extends java.net.SocketAddress> localAddresses) throws java.lang.Exception
bindInternal
在类中 AbstractIoAcceptor
localAddresses
- The address to bind toSet
of the local addresses which is bound actuallyjava.lang.Exception
- If the bind failedprotected void close(java.nio.channels.DatagramChannel handle) throws java.lang.Exception
java.lang.Exception
protected void destroy() throws java.lang.Exception
java.lang.Exception
protected void dispose0() throws java.lang.Exception
AbstractIoService.dispose()
.dispose0
在类中 AbstractIoService
java.lang.Exception
- If the dispose failedpublic void flush(NioSession session)
session
.flush
在接口中 IoProcessor<NioSession>
session
- The session we want the message to be writtenpublic java.net.InetSocketAddress getDefaultLocalAddress()
AbstractIoAcceptor
IoAcceptor.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
在接口中 IoAcceptor
getDefaultLocalAddress
在接口中 DatagramAcceptor
getDefaultLocalAddress
在类中 AbstractIoAcceptor
public java.net.InetSocketAddress getLocalAddress()
AbstractIoAcceptor
getLocalAddress
在接口中 IoAcceptor
getLocalAddress
在接口中 DatagramAcceptor
getLocalAddress
在类中 AbstractIoAcceptor
public DatagramSessionConfig getSessionConfig()
getSessionConfig
在接口中 IoService
getSessionConfig
在接口中 DatagramAcceptor
IoSession
s
created by this service.public final IoSessionRecycler getSessionRecycler()
getSessionRecycler
在接口中 DatagramAcceptor
IoSessionRecycler
for this service.public TransportMetadata getTransportMetadata()
getTransportMetadata
在接口中 IoService
TransportMetadata
that this service runs on.protected boolean isReadable(java.nio.channels.DatagramChannel handle)
protected boolean isWritable(java.nio.channels.DatagramChannel handle)
protected java.net.SocketAddress localAddress(java.nio.channels.DatagramChannel handle) throws java.lang.Exception
java.lang.Exception
protected NioSession newSession(IoProcessor<NioSession> processor, java.nio.channels.DatagramChannel handle, java.net.SocketAddress remoteAddress)
public final IoSession newSession(java.net.SocketAddress remoteAddress, java.net.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
在接口中 IoAcceptor
remoteAddress
- The remote address bound to the servicelocalAddress
- The local address the session will be bound toprotected java.nio.channels.DatagramChannel open(java.net.SocketAddress localAddress) throws java.lang.Exception
java.lang.Exception
protected java.net.SocketAddress receive(java.nio.channels.DatagramChannel handle, IoBuffer buffer) throws java.lang.Exception
java.lang.Exception
public 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
在接口中 IoProcessor<NioSession>
session
- The session to be removedprotected int select() throws java.lang.Exception
java.lang.Exception
protected int select(long timeout) throws java.lang.Exception
java.lang.Exception
protected java.util.Set<java.nio.channels.SelectionKey> selectedHandles()
protected int send(NioSession session, IoBuffer buffer, java.net.SocketAddress remoteAddress) throws java.lang.Exception
java.lang.Exception
public void setDefaultLocalAddress(java.net.InetSocketAddress localAddress)
DatagramAcceptor
IoAcceptor.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
在接口中 DatagramAcceptor
localAddress
- The local addressprotected void setInterestedInWrite(NioSession session, boolean isInterested) throws java.lang.Exception
java.lang.Exception
public final void setSessionRecycler(IoSessionRecycler sessionRecycler)
DatagramAcceptor
IoSessionRecycler
for this service.setSessionRecycler
在接口中 DatagramAcceptor
sessionRecycler
- null to use the default recyclerprotected final void unbind0(java.util.List<? extends java.net.SocketAddress> localAddresses) throws java.lang.Exception
unbind0
在类中 AbstractIoAcceptor
localAddresses
- The address to unbind fromjava.lang.Exception
- If the unbind failedpublic void updateTrafficControl(NioSession session)
session
depending of the
IoSession.isReadSuspended()
and IoSession.isWriteSuspended()
flagsupdateTrafficControl
在接口中 IoProcessor<NioSession>
session
- The session to be updatedprotected void wakeup()
public void write(NioSession session, WriteRequest writeRequest)
session
.write
在接口中 IoProcessor<NioSession>
session
- The session we want the message to be writtenwriteRequest
- the WriteRequest to write