public class SocketConnector
extends org.apache.mina.common.support.BaseIoConnector
IoConnector
for socket transport (TCP/IP).Constructor and Description |
---|
SocketConnector()
Create a connector with a single processing thread using a NewThreadExecutor
|
SocketConnector(int processorCount,
edu.emory.mathcs.backport.java.util.concurrent.Executor executor)
Create a connector with the desired number of processing threads
|
Modifier and Type | Method and Description |
---|---|
ConnectFuture |
connect(java.net.SocketAddress address,
IoHandler handler,
IoServiceConfig config)
Connects to the specified
address . |
ConnectFuture |
connect(java.net.SocketAddress address,
java.net.SocketAddress localAddress,
IoHandler handler,
IoServiceConfig config)
Connects to the specified
address . |
IoServiceConfig |
getDefaultConfig()
Returns the default configuration which is used when you didn't specify
any configuration.
|
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.
|
addListener, getFilterChain, getFilterChainBuilder, getListeners, getManagedServiceAddresses, getManagedSessions, isManaged, removeListener, setFilterChainBuilder
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addListener, getFilterChain, getFilterChainBuilder, getManagedServiceAddresses, getManagedSessions, isManaged, removeListener, setFilterChainBuilder
public SocketConnector()
public SocketConnector(int processorCount, edu.emory.mathcs.backport.java.util.concurrent.Executor executor)
processorCount
- Number of processing threadsexecutor
- Executor to use for launching threadspublic int getWorkerTimeout()
public void setWorkerTimeout(int workerTimeout)
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.public ConnectFuture connect(java.net.SocketAddress address, IoHandler handler, IoServiceConfig config)
IoConnector
address
. If communication starts
successfully, events are fired to the specified
handler
.config
- the configurationConnectFuture
that will tell the result of the connection attemptpublic ConnectFuture connect(java.net.SocketAddress address, java.net.SocketAddress localAddress, IoHandler handler, IoServiceConfig config)
IoConnector
address
. If communication starts
successfully, events are fired to the specified
handler
.config
- the configurationConnectFuture
that will tell the result of the connection attemptpublic IoServiceConfig getDefaultConfig()
IoService
public void setDefaultConfig(SocketConnectorConfig defaultConfig)
defaultConfig
- the default config.java.lang.NullPointerException
- if the specified value is null
.Copyright © 2004-2019 Apache MINA Project. All Rights Reserved.