public final class NioSocketAcceptor extends AbstractPollingIoAcceptor<NioSession,java.nio.channels.ServerSocketChannel> implements SocketAcceptor
IoAcceptor for socket transport (TCP/IP). This class
handles incoming TCP/IP based socket connections.AbstractIoAcceptor.AcceptorOperationFutureAbstractIoService.ServiceOperationFuturebacklog, reuseAddressbindLockdisposalLock, sessionConfig| 构造器和说明 |
|---|
NioSocketAcceptor()
Constructor for
NioSocketAcceptor using default parameters (multiple thread model). |
NioSocketAcceptor(java.util.concurrent.Executor executor,
IoProcessor<NioSession> processor)
Constructor for
NioSocketAcceptor with a given Executor for handling
connection events and a given IoProcessor for handling I/O events, useful for
sharing the same processor and executor over multiple IoService of the same type. |
NioSocketAcceptor(int processorCount)
Constructor for
NioSocketAcceptor using default parameters, and
given number of NioProcessor for multithreading I/O operations. |
NioSocketAcceptor(int processorCount,
java.nio.channels.spi.SelectorProvider selectorProvider)
Constructor for
NioSocketAcceptor using default parameters, and
given number of NioProcessor for multithreading I/O operations, and
a custom SelectorProvider for NIO |
NioSocketAcceptor(IoProcessor<NioSession> processor)
Constructor for
NioSocketAcceptor with default configuration but a
specific IoProcessor, useful for sharing the same processor over multiple
IoService of the same type. |
| 限定符和类型 | 方法和说明 |
|---|---|
protected NioSession |
accept(IoProcessor<NioSession> processor,
java.nio.channels.ServerSocketChannel handle)
Accept a client connection for a server socket and return a new
IoSession
associated with the given IoProcessor |
protected void |
close(java.nio.channels.ServerSocketChannel handle)
Close a server socket.
|
protected void |
destroy()
Destroy the polling system, will be called when this
IoAcceptor
implementation will be disposed. |
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.
|
TransportMetadata |
getTransportMetadata() |
protected void |
init()
Initialize the polling system, will be called at construction time.
|
protected void |
init(java.nio.channels.spi.SelectorProvider selectorProvider)
Initialize the polling system, will be called at construction time.
|
protected java.net.SocketAddress |
localAddress(java.nio.channels.ServerSocketChannel handle)
Get the local address associated with a given server socket
|
protected java.nio.channels.ServerSocketChannel |
open(java.net.SocketAddress localAddress)
Open a server socket for a given local address.
|
protected int |
select()
Check if we have at least one key whose corresponding channels is
ready for I/O operations.
|
protected java.util.Iterator<java.nio.channels.ServerSocketChannel> |
selectedHandles()
Iterator for the set of server sockets found with acceptable incoming connections
during the last AbstractPollingIoAcceptor.select() call. |
void |
setDefaultLocalAddress(java.net.InetSocketAddress localAddress)
Sets the default local InetSocketAddress to bind when no argument is specified in
IoAcceptor.bind() method. |
protected void |
wakeup()
Interrupt the
AbstractPollingIoAcceptor.select() method. |
bindInternal, dispose0, getBacklog, getSessionConfig, isReuseAddress, newSession, setBacklog, setReuseAddress, unbind0bind, 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, waitgetBacklog, getSessionConfig, isReuseAddress, setBacklog, setReuseAddressbind, bind, bind, bind, bind, getDefaultLocalAddresses, getLocalAddresses, isCloseOnDeactivation, newSession, 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, setSessionDataStructureFactorypublic NioSocketAcceptor()
NioSocketAcceptor using default parameters (multiple thread model).public NioSocketAcceptor(int processorCount)
NioSocketAcceptor using default parameters, and
given number of NioProcessor for multithreading I/O operations.processorCount - the number of processor to create and place in a
SimpleIoProcessorPoolpublic NioSocketAcceptor(IoProcessor<NioSession> processor)
NioSocketAcceptor with default configuration but a
specific IoProcessor, useful for sharing the same processor over multiple
IoService of the same type.processor - the processor to use for managing I/O eventspublic NioSocketAcceptor(java.util.concurrent.Executor executor,
IoProcessor<NioSession> processor)
NioSocketAcceptor with a given Executor for handling
connection events and a given IoProcessor for handling I/O events, useful for
sharing the same processor and executor over multiple IoService of the same type.executor - the executor for connectionprocessor - the processor for I/O operationspublic NioSocketAcceptor(int processorCount,
java.nio.channels.spi.SelectorProvider selectorProvider)
NioSocketAcceptor using default parameters, and
given number of NioProcessor for multithreading I/O operations, and
a custom SelectorProvider for NIOprocessorCount - the number of processor to create and place in aselectorProvider - teh SelectorProvider to use
SimpleIoProcessorPoolprotected void init()
throws java.lang.Exception
init 在类中 AbstractPollingIoAcceptor<NioSession,java.nio.channels.ServerSocketChannel>java.lang.Exception - any exception thrown by the underlying system callsprotected void init(java.nio.channels.spi.SelectorProvider selectorProvider)
throws java.lang.Exception
init 在类中 AbstractPollingIoAcceptor<NioSession,java.nio.channels.ServerSocketChannel>selectorProvider - The Selector Provider that will be used by this polling acceptorjava.lang.Exception - any exception thrown by the underlying system callsprotected void destroy()
throws java.lang.Exception
IoAcceptor
implementation will be disposed.destroy 在类中 AbstractPollingIoAcceptor<NioSession,java.nio.channels.ServerSocketChannel>java.lang.Exception - any exception thrown by the underlying systems callspublic TransportMetadata getTransportMetadata()
getTransportMetadata 在接口中 IoServiceTransportMetadata that this service runs on.public java.net.InetSocketAddress getLocalAddress()
getLocalAddress 在接口中 IoAcceptorgetLocalAddress 在接口中 SocketAcceptorgetLocalAddress 在类中 AbstractIoAcceptorpublic java.net.InetSocketAddress getDefaultLocalAddress()
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 在接口中 IoAcceptorgetDefaultLocalAddress 在接口中 SocketAcceptorgetDefaultLocalAddress 在类中 AbstractIoAcceptorpublic void setDefaultLocalAddress(java.net.InetSocketAddress localAddress)
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 在接口中 SocketAcceptorlocalAddress - The local addressprotected NioSession accept(IoProcessor<NioSession> processor, java.nio.channels.ServerSocketChannel handle) throws java.lang.Exception
IoSession
associated with the given IoProcessoraccept 在类中 AbstractPollingIoAcceptor<NioSession,java.nio.channels.ServerSocketChannel>processor - the IoProcessor to associate with the IoSessionhandle - the server handleIoSessionjava.lang.Exception - any exception thrown by the underlying systems callsprotected java.nio.channels.ServerSocketChannel open(java.net.SocketAddress localAddress)
throws java.lang.Exception
open 在类中 AbstractPollingIoAcceptor<NioSession,java.nio.channels.ServerSocketChannel>localAddress - the associated local addressjava.lang.Exception - any exception thrown by the underlying systems callsprotected java.net.SocketAddress localAddress(java.nio.channels.ServerSocketChannel handle)
throws java.lang.Exception
localAddress 在类中 AbstractPollingIoAcceptor<NioSession,java.nio.channels.ServerSocketChannel>handle - the server socketSocketAddress associated with this handlejava.lang.Exception - any exception thrown by the underlying systems callsprotected int select()
throws java.lang.Exception
select 在类中 AbstractPollingIoAcceptor<NioSession,java.nio.channels.ServerSocketChannel>java.io.IOException - If an I/O error occursjava.nio.channels.ClosedSelectorException - If this selector is closedjava.lang.Exception - any exception thrown by the underlying systems callsprotected java.util.Iterator<java.nio.channels.ServerSocketChannel> selectedHandles()
Iterator for the set of server sockets found with acceptable incoming connections
during the last AbstractPollingIoAcceptor.select() call.selectedHandles 在类中 AbstractPollingIoAcceptor<NioSession,java.nio.channels.ServerSocketChannel>protected void close(java.nio.channels.ServerSocketChannel handle)
throws java.lang.Exception
close 在类中 AbstractPollingIoAcceptor<NioSession,java.nio.channels.ServerSocketChannel>handle - the server socketjava.lang.Exception - any exception thrown by the underlying systems callsprotected void wakeup()
AbstractPollingIoAcceptor.select() method. Used when the poll set need to be modified.wakeup 在类中 AbstractPollingIoAcceptor<NioSession,java.nio.channels.ServerSocketChannel>