Package org.apache.mina.common
Interface IoAcceptor
-
- All Superinterfaces:
IoService
- All Known Implementing Classes:
BaseIoAcceptor,DatagramAcceptor,DatagramAcceptorDelegate,DelegatedIoAcceptor,SocketAcceptor,VmPipeAcceptor
public interface IoAcceptor extends IoService
Accepts incoming connection, communicates with clients, and fires events toIoHandlers.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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidbind(java.net.SocketAddress address, IoHandler handler)Binds to the specifiedaddressand handles incoming connections with the specifiedhandler.voidbind(java.net.SocketAddress address, IoHandler handler, IoServiceConfig config)Binds to the specifiedaddressand handles incoming connections with the specifiedhandler.IoSessionnewSession(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)(Optional) Returns anIoSessionthat is bound to the specified localAddress and remoteAddress which reuses the localAddress that is already bound byIoAcceptorviabind(SocketAddress, IoHandler).voidunbind(java.net.SocketAddress address)Unbinds from the specifiedaddressand disconnects all clients connected there.voidunbindAll()Unbinds all addresses which were bound by this acceptor.-
Methods inherited from interface org.apache.mina.common.IoService
addListener, getDefaultConfig, getFilterChain, getFilterChainBuilder, getManagedServiceAddresses, getManagedSessions, isManaged, removeListener, setFilterChainBuilder
-
-
-
-
Method Detail
-
bind
void bind(java.net.SocketAddress address, IoHandler handler) throws java.io.IOExceptionBinds to the specifiedaddressand handles incoming connections with the specifiedhandler.- Throws:
java.io.IOException- if failed to bind
-
bind
void bind(java.net.SocketAddress address, IoHandler handler, IoServiceConfig config) throws java.io.IOExceptionBinds to the specifiedaddressand handles incoming connections with the specifiedhandler.- Parameters:
config- the configuration- Throws:
java.io.IOException- if failed to bind
-
unbind
void unbind(java.net.SocketAddress address)
Unbinds from the specifiedaddressand disconnects all clients connected there.
-
unbindAll
void unbindAll()
Unbinds all addresses which were bound by this acceptor.
-
newSession
IoSession newSession(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
(Optional) Returns anIoSessionthat is bound to the specified localAddress and remoteAddress which reuses the localAddress that is already bound byIoAcceptorviabind(SocketAddress, IoHandler).This operation is optional. Please throw
UnsupportedOperationExceptionif the transport type doesn't support this operation. This operation is usually implemented for connectionless transport types.- Throws:
java.lang.UnsupportedOperationException- if this operation is not supportedjava.lang.IllegalArgumentException- if the specified localAddress is not bound yet. (seebind(SocketAddress, IoHandler))
-
-