|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IoAcceptor
Accepts incoming connection, communicates with clients, and fires events to
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()
is invoked, and stop when unbind()
is invoked.
Method Summary | |
---|---|
void |
bind()
Binds to the default local address(es) and start to accept incoming connections. |
void |
bind(Iterable<? extends SocketAddress> localAddresses)
Binds to the specified local addresses and start to accept incoming connections. |
void |
bind(SocketAddress localAddress)
Binds to the specified local address and start to accept incoming connections. |
void |
bind(SocketAddress firstLocalAddress,
SocketAddress... otherLocalAddresses)
Binds to the specified local addresses and start to accept incoming connections. |
SocketAddress |
getDefaultLocalAddress()
Returns the default local address to bind when no argument is specified in bind() method. |
List<SocketAddress> |
getDefaultLocalAddresses()
Returns a List of the default local addresses to bind when no
argument is specified in bind() method. |
SocketAddress |
getLocalAddress()
Returns the local address which is bound currently. |
Set<SocketAddress> |
getLocalAddresses()
Returns a Set of the local addresses which are bound currently. |
boolean |
isCloseOnDeactivation()
Returns true if and only if all clients are closed when this acceptor unbinds from all the related local address (i.e. when the service is deactivated). |
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. |
void |
setCloseOnDeactivation(boolean closeOnDeactivation)
Sets whether all client sessions are closed when this acceptor unbinds from all the related local addresses (i.e. when the service is deactivated). |
void |
setDefaultLocalAddress(SocketAddress localAddress)
Sets the default local address to bind when no argument is specified in bind() method. |
void |
setDefaultLocalAddresses(Iterable<? extends SocketAddress> localAddresses)
Sets the default local addresses to bind when no argument is specified in bind() method. |
void |
setDefaultLocalAddresses(List<? extends SocketAddress> localAddresses)
Sets the default local addresses to bind when no argument is specified in bind() method. |
void |
setDefaultLocalAddresses(SocketAddress firstLocalAddress,
SocketAddress... otherLocalAddresses)
Sets the default local addresses to bind when no argument is specified in bind() method. |
void |
unbind()
Unbinds from all local addresses that this service is bound to and stops to accept incoming connections. |
void |
unbind(Iterable<? extends SocketAddress> localAddresses)
Unbinds from the specified local addresses and stop to accept incoming connections. |
void |
unbind(SocketAddress localAddress)
Unbinds from the specified local address and stop to accept incoming connections. |
void |
unbind(SocketAddress firstLocalAddress,
SocketAddress... otherLocalAddresses)
Unbinds from the specified local addresses and stop to accept incoming connections. |
Methods inherited from interface org.apache.mina.core.service.IoService |
---|
addListener, broadcast, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getIdleState, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionConfig, getSessionDataStructureFactory, getStatistics, getTransportMetadata, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory |
Method Detail |
---|
SocketAddress getLocalAddress()
Set<SocketAddress> getLocalAddresses()
Set
of the local addresses which are bound currently.
SocketAddress getDefaultLocalAddress()
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 setDefaultLocalAddresses(List)
.
List<SocketAddress> getDefaultLocalAddresses()
List
of the default local addresses to bind when no
argument is specified in bind()
method. Please note that the
default will not be used if any local address is specified.
void setDefaultLocalAddress(SocketAddress localAddress)
bind()
method. Please note that the default will not be used
if any local address is specified.
void setDefaultLocalAddresses(SocketAddress firstLocalAddress, SocketAddress... otherLocalAddresses)
bind()
method. Please note that the default will not be
used if any local address is specified.
void setDefaultLocalAddresses(Iterable<? extends SocketAddress> localAddresses)
bind()
method. Please note that the default will not be
used if any local address is specified.
void setDefaultLocalAddresses(List<? extends SocketAddress> localAddresses)
bind()
method. Please note that the default will not be
used if any local address is specified.
boolean isCloseOnDeactivation()
void setCloseOnDeactivation(boolean closeOnDeactivation)
void bind() throws IOException
IOException
- if failed to bindvoid bind(SocketAddress localAddress) throws IOException
IOException
- if failed to bindvoid bind(SocketAddress firstLocalAddress, SocketAddress... otherLocalAddresses) throws IOException
IOException
- if failed to bindvoid bind(Iterable<? extends SocketAddress> localAddresses) throws IOException
IOException
- if failed to bindvoid unbind()
disconnectOnUnbind
property
is true. This method returns silently if no local address is
bound yet.
void unbind(SocketAddress localAddress)
disconnectOnUnbind
property is
true. This method returns silently if the default local
address is not bound yet.
void unbind(SocketAddress firstLocalAddress, SocketAddress... otherLocalAddresses)
disconnectOnUnbind
property is
true. This method returns silently if the default local
addresses are not bound yet.
void unbind(Iterable<? extends SocketAddress> localAddresses)
disconnectOnUnbind
property is
true. This method returns silently if the default local
addresses are not bound yet.
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.
UnsupportedOperationException
- if this operation is not supported
IllegalStateException
- if this service is not running.
IllegalArgumentException
- if this service is not bound to the
specified localAddress.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |