public class SocketConnector extends BaseIoConnector
IoConnector
for socket transport (TCP/IP).构造器和说明 |
---|
SocketConnector()
Create a connector with a single processing thread using a NewThreadExecutor
|
SocketConnector(int processorCount,
java.util.concurrent.Executor executor)
Create a connector with the desired number of processing threads
|
限定符和类型 | 方法和说明 |
---|---|
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 . |
SocketConnectorConfig |
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.
|
connect, connect
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, 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 SocketConnectorConfig getDefaultConfig()
IoService
public void setDefaultConfig(SocketConnectorConfig defaultConfig)
defaultConfig
- the default config.java.lang.NullPointerException
- if the specified value is null
.