public class NioTcpServer extends AbstractTcpServer implements SelectorListener
AbstractIoService.ServiceState
config, ioHandlerExecutor
Constructor and Description |
---|
NioTcpServer()
Create a TCP server with new selector pool of default size and a
IoHandlerExecutor of default type (
OrderedHandlerExecutor ) |
NioTcpServer(SelectorLoopPool selectorLoopPool,
IoHandlerExecutor handlerExecutor)
Create a TCP server with provided selector loops pool.
|
NioTcpServer(SelectorLoop acceptSelectorLoop,
SelectorLoopPool readWriteSelectorLoop,
IoHandlerExecutor handlerExecutor)
Create a TCP server with provided selector loops pool
|
NioTcpServer(TcpSessionConfig config)
Create a TCP server with new selector pool of default size and a
IoHandlerExecutor of default type (
OrderedHandlerExecutor ) |
NioTcpServer(TcpSessionConfig config,
SelectorLoopPool selectorLoopPool,
IoHandlerExecutor handlerExecutor)
Create a TCP server with provided selector loops pool.
|
NioTcpServer(TcpSessionConfig config,
SelectorLoop acceptSelectorLoop,
SelectorLoopPool readWriteSelectorLoop,
IoHandlerExecutor handlerExecutor)
Create a TCP server with provided selector loops pool
|
Modifier and Type | Method and Description |
---|---|
void |
bind(int port)
Binds the server to the specified port.
|
void |
bind(SocketAddress localAddress)
Binds to the specified local addresses and start to accept incoming connections.
|
SelectionKey |
getAcceptKey() |
SocketAddress |
getBoundAddress()
Returns the local addresses which are bound currently.
|
ServerSocketChannel |
getServerSocketChannel()
Get the inner Server socket for accepting new client connections
|
void |
ready(boolean accept,
boolean connect,
boolean read,
ByteBuffer readBuffer,
boolean write) |
void |
setAcceptKey(SelectionKey acceptKey) |
void |
setServerSocketChannel(ServerSocketChannel serverChannel) |
void |
unbind()
Unbinds from the local addresses that this service is bound to and stops to accept incoming connections.
|
getSessionConfig, setSessionConfig
isReuseAddress, setReuseAddress, setSessionConfig
fireServiceActivated, fireServiceInactivated, getFilters, getIoHandler, getIoHandlerExecutor, getManagedSessions, initState, isActive, isCreated, isDisposed, isDisposing, isSuspended, setActive, setCreated, setDisposed, setDisposing, setFilters, setIoHandler, setSuspended
public NioTcpServer()
IoHandlerExecutor
of default type (
OrderedHandlerExecutor
)public NioTcpServer(TcpSessionConfig config)
IoHandlerExecutor
of default type (
OrderedHandlerExecutor
)config
- The specific configuration to usepublic NioTcpServer(SelectorLoopPool selectorLoopPool, IoHandlerExecutor handlerExecutor)
selectorLoopPool
- the selector loop pool for handling all I/O events (accept, read, write)ioHandlerExecutor
- used for executing IoHandler event in another pool of thread (not in the low level I/O
one). Use null
if you don't want one. Be careful, the IoHandler processing will block the I/O
operations.public NioTcpServer(TcpSessionConfig config, SelectorLoopPool selectorLoopPool, IoHandlerExecutor handlerExecutor)
config
- The specific configuration to useselectorLoopPool
- the selector loop pool for handling all I/O events (accept, read, write)ioHandlerExecutor
- used for executing IoHandler event in another pool of thread (not in the low level I/O
one). Use null
if you don't want one. Be careful, the IoHandler processing will block the I/O
operations.public NioTcpServer(SelectorLoop acceptSelectorLoop, SelectorLoopPool readWriteSelectorLoop, IoHandlerExecutor handlerExecutor)
acceptSelectorLoop
- the selector loop for handling accept events (connection of new session)readWriteSelectorLoop
- the pool of selector loop for handling read/write events of connected sessionsioHandlerExecutor
- used for executing IoHandler event in another pool of thread (not in the low level I/O
one). Use null
if you don't want one. Be careful, the IoHandler processing will block the I/O
operations.public NioTcpServer(TcpSessionConfig config, SelectorLoop acceptSelectorLoop, SelectorLoopPool readWriteSelectorLoop, IoHandlerExecutor handlerExecutor)
config
- The specific configuration to useacceptSelectorLoop
- the selector loop for handling accept events (connection of new session)readWriteSelectorLoop
- the pool of selector loop for handling read/write events of connected sessionsioHandlerExecutor
- used for executing IoHandler event in another pool of thread (not in the low level I/O
one). Use null
if you don't want one. Be careful, the IoHandler processing will block the I/O
operations.public ServerSocketChannel getServerSocketChannel()
public void setServerSocketChannel(ServerSocketChannel serverChannel)
public void bind(int port)
public void bind(SocketAddress localAddress)
public SocketAddress getBoundAddress()
getBoundAddress
in interface IoServer
public void unbind()
public SelectionKey getAcceptKey()
public void setAcceptKey(SelectionKey acceptKey)
acceptKey
- the acceptKey to setpublic void ready(boolean accept, boolean connect, boolean read, ByteBuffer readBuffer, boolean write)
ready
in interface SelectorListener
Copyright © 2009–2013 Apache MINA Project. All rights reserved.