public interface IoAcceptor extends IoService
IoHandler
s.
Please refer to EchoServer example.
You should bind to the desired socket address to accept incoming
connections, and then events for incoming connections will be sent to
the specified default IoHandler
.
Threads accept incoming connections start automatically when
bind(SocketAddress, IoHandler)
is invoked, and stop when all
addresses are unbound.
限定符和类型 | 方法和说明 |
---|---|
void |
bind(java.net.SocketAddress address,
IoHandler handler)
Binds to the specified
address and handles incoming
connections with the specified handler . |
void |
bind(java.net.SocketAddress address,
IoHandler handler,
IoServiceConfig config)
Binds to the specified
address and handles incoming
connections with the specified handler . |
IoSession |
newSession(java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress)
(Optional) Returns an
IoSession that is bound to the specified
localAddress and remoteAddress which reuses
the localAddress that is already bound by IoAcceptor
via bind(SocketAddress, IoHandler) . |
void |
unbind(java.net.SocketAddress address)
Unbinds from the specified
address and disconnects all clients
connected there. |
void |
unbindAll()
Unbinds all addresses which were bound by this acceptor.
|
addListener, getDefaultConfig, getFilterChain, getFilterChainBuilder, getManagedServiceAddresses, getManagedSessions, isManaged, removeListener, setFilterChainBuilder
void bind(java.net.SocketAddress address, IoHandler handler) throws java.io.IOException
address
and handles incoming
connections with the specified handler
.java.io.IOException
- if failed to bindvoid bind(java.net.SocketAddress address, IoHandler handler, IoServiceConfig config) throws java.io.IOException
address
and handles incoming
connections with the specified handler
.config
- the configurationjava.io.IOException
- if failed to bindvoid unbind(java.net.SocketAddress address)
address
and disconnects all clients
connected there.void unbindAll()
IoSession newSession(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
IoSession
that is bound to the specified
localAddress and remoteAddress which reuses
the localAddress that is already bound by IoAcceptor
via bind(SocketAddress, IoHandler)
.
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.
java.lang.UnsupportedOperationException
- if this operation is not supportedjava.lang.IllegalArgumentException
- if the specified localAddress is
not bound yet. (see bind(SocketAddress, IoHandler)
)