org.apache.mina.transport.socket.nio

Class SocketConnector

Implemented Interfaces:
IoConnector, IoService

public class SocketConnector
extends BaseIoConnector

IoConnector for socket transport (TCP/IP).

Constructor Summary

SocketConnector()
Create a connector with a single processing thread using a NewThreadExecutor
SocketConnector(int processorCount, Executor executor)
Create a connector with the desired number of processing threads

Method Summary

ConnectFuture
connect(SocketAddress address, SocketAddress localAddress, IoHandler handler, IoServiceConfig config)
ConnectFuture
connect(SocketAddress address, IoHandler handler, IoServiceConfig config)
SocketConnectorConfig
getDefaultConfig()
int
getWorkerTimeout()
How many seconds to keep the connection thread alive between connection requests
void
setDefaultConfig(SocketConnectorConfig defaultConfig)
Sets the config this connector will use by default.
void
setWorkerTimeout(int workerTimeout)
Set how many seconds the connection worker thread should remain alive once idle before terminating itself.

Methods inherited from class org.apache.mina.common.support.BaseIoConnector

connect, connect

Methods inherited from class org.apache.mina.common.support.BaseIoService

addListener, getFilterChain, getFilterChainBuilder, getListeners, getManagedServiceAddresses, getManagedSessions, isManaged, removeListener, setFilterChainBuilder

Constructor Details

SocketConnector

public SocketConnector()
Create a connector with a single processing thread using a NewThreadExecutor

SocketConnector

public SocketConnector(int processorCount,
                       Executor executor)
Create a connector with the desired number of processing threads
Parameters:
processorCount - Number of processing threads
executor - Executor to use for launching threads

Method Details

connect

public ConnectFuture connect(SocketAddress address,
                             SocketAddress localAddress,
                             IoHandler handler,
                             IoServiceConfig config)
Specified by:
connect in interface IoConnector

connect

public ConnectFuture connect(SocketAddress address,
                             IoHandler handler,
                             IoServiceConfig config)
Specified by:
connect in interface IoConnector

getDefaultConfig

public SocketConnectorConfig getDefaultConfig()
Specified by:
getDefaultConfig in interface IoService

getWorkerTimeout

public int getWorkerTimeout()
How many seconds to keep the connection thread alive between connection requests
Returns:
the number of seconds to keep connection thread alive. 0 means that the connection thread will terminate immediately when there's no connection to make.

setDefaultConfig

public void setDefaultConfig(SocketConnectorConfig defaultConfig)
Sets the config this connector will use by default.
Parameters:
defaultConfig - the default config.

setWorkerTimeout

public void setWorkerTimeout(int workerTimeout)
Set how many seconds the connection worker thread should remain alive once idle before terminating itself.
Parameters:
workerTimeout - the number of seconds to keep thread alive. Must be >=0. If 0 is specified, the connection worker thread will terminate immediately when there's no connection to make.