org.apache.mina.transport.nio

## Class NioTcpClient

- java.lang.Object
- - org.apache.mina.service.AbstractIoService
  - - org.apache.mina.service.client.AbstractIoClient
    - - org.apache.mina.transport.tcp.AbstractTcpClient
      - - org.apache.mina.transport.nio.NioTcpClient

All Implemented Interfaces:
  IoClient, IoService

    public class NioTcpClient
    extends AbstractTcpClient

This class implements a TCP NIO based client.

Author:
  Apache MINA Project

### Nested Class Summary

### Nested classes/interfaces inherited from class org.apache.mina.service.AbstractIoService

`AbstractIoService.ServiceState`

### Field Summary

### Fields inherited from class org.apache.mina.service.AbstractIoService

`config, ioHandlerExecutor`

### Constructor Summary

Constructors
Constructor and Description
`NioTcpClient()` Create a TCP client with new selector pool of default size and a `IoHandlerExecutor` of default type ( `OrderedHandlerExecutor`)
`NioTcpClient(SelectorLoopPool selectorLoopPool, IoHandlerExecutor handlerExecutor)` Create a TCP client with provided selector loops pool.
`NioTcpClient(SelectorLoop connectSelectorLoop, SelectorLoopPool readWriteSelectorLoop, IoHandlerExecutor handlerExecutor)` Create a TCP client with provided selector loops pool

### Method Summary

Methods
`IoFuture<IoSession>` `connect(SocketAddress remoteAddress)` Connects to the specified remote address.
`void` `disconnect()`

### Methods inherited from class org.apache.mina.transport.tcp.AbstractTcpClient

`getConnectTimeoutMillis, getSessionConfig, setConnectTimeoutMillis, setSessionConfig`

### Methods inherited from class org.apache.mina.service.AbstractIoService

`fireServiceActivated, fireServiceInactivated, getFilters, getIoHandler, getIoHandlerExecutor, getManagedSessions, initState, isActive, isCreated, isDisposed, isDisposing, isSuspended, setActive, setCreated, setDisposed, setDisposing, setFilters, setIoHandler, setSuspended`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### NioTcpClient

    public NioTcpClient()

Create a TCP client with new selector pool of default size and a `IoHandlerExecutor` of default type ( `OrderedHandlerExecutor`)

#### NioTcpClient

    public NioTcpClient(SelectorLoopPool selectorLoopPool,
                IoHandlerExecutor handlerExecutor)

Create a TCP client with provided selector loops pool. We will use one SelectorLoop get from the pool to manage the OP_CONNECT events. If the pool contains only one SelectorLoop, then all the events will be managed by the same Selector.

Parameters:
  `readWriteSelectorLoop` - the pool of selector loop for handling read/write events of connected sessions
  `ioHandlerExecutor` - used for executing IoHandler event in another pool of thread (not in the low level I/O one). Use `null` if you don't want one. Be careful, the IoHandler processing will block the I/O operations.

#### NioTcpClient

    public NioTcpClient(SelectorLoop connectSelectorLoop,
                SelectorLoopPool readWriteSelectorLoop,
                IoHandlerExecutor handlerExecutor)

Create a TCP client with provided selector loops pool

Parameters:
  `connectSelectorLoop` - the selector loop for handling connection events (connection of new session)
  `readWriteSelectorLoop` - the pool of selector loop for handling read/write events of connected sessions
  `ioHandlerExecutor` - used for executing IoHandler event in another pool of thread (not in the low level I/O one). Use `null` if you don't want one. Be careful, the IoHandler processing will block the I/O operations.

### Method Detail

#### connect

    public IoFuture<IoSession> connect(SocketAddress remoteAddress)

Connects to the specified remote address.

Parameters:
  `remoteAddress` - Remote `SocketAddress` to connect
Returns:
  the `IoFuture` instance which is completed when the connection attempt initiated by this call succeeds or fails.

#### disconnect

    public void disconnect()
                    throws IOException

Throws:
  `IOException`