org.apache.mina.core.service

## Interface IoConnector

- All Superinterfaces:
    IoService
  All Known Subinterfaces:
    DatagramConnector, SocketConnector
  All Known Implementing Classes:
    AbstractIoConnector, AbstractPollingIoConnector, AprSocketConnector, NioDatagramConnector, NioSocketConnector, ProxyConnector, SerialConnector, VmPipeConnector

      public interface IoConnector
      extends IoService

  Connects to endpoint, communicates with the server, and fires events to `IoHandler`s.

  Please refer to NetCat example.

  You should connect to the desired socket address to start communication, and then events for incoming connections will be sent to the specified default `IoHandler`.

  Threads connect to endpoint start automatically when `connect(SocketAddress)` is invoked, and stop when all connection attempts are finished.

  Author:
    Apache MINA Project

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ConnectFuture` | `connect()` Connects to the `default remote address`.
    `ConnectFuture` | `connect(IoSessionInitializer<? extends ConnectFuture> sessionInitializer)` Connects to the `default remote address` and invokes the `ioSessionInitializer` when the IoSession is created but before `IoHandler.sessionCreated(IoSession)` is invoked.
    `ConnectFuture` | `connect(SocketAddress remoteAddress)` Connects to the specified remote address.
    `ConnectFuture` | `connect(SocketAddress remoteAddress, IoSessionInitializer<? extends ConnectFuture> sessionInitializer)` Connects to the specified remote address and invokes the `ioSessionInitializer` when the IoSession is created but before `IoHandler.sessionCreated(IoSession)` is invoked.
    `ConnectFuture` | `connect(SocketAddress remoteAddress, SocketAddress localAddress)` Connects to the specified remote address binding to the specified local address.
    `ConnectFuture` | `connect(SocketAddress remoteAddress, SocketAddress localAddress, IoSessionInitializer<? extends ConnectFuture> sessionInitializer)` Connects to the specified remote address binding to the specified local address and and invokes the `ioSessionInitializer` when the IoSession is created but before `IoHandler.sessionCreated(IoSession)` is invoked.
    `int` | `getConnectTimeout()` Deprecated.
    `long` | `getConnectTimeoutMillis()` Returns the connect timeout in milliseconds.
    `SocketAddress` | `getDefaultRemoteAddress()` Returns the default remote address to connect to when no argument is specified in `connect()` method.
    `void` | `setConnectTimeout(int connectTimeout)` Deprecated.
    `void` | `setConnectTimeoutMillis(long connectTimeoutInMillis)` Sets the connect timeout in milliseconds.
    `void` | `setDefaultRemoteAddress(SocketAddress defaultRemoteAddress)` Sets the default remote address to connect to when no argument is specified in `connect()` method.

    - ### Methods inherited from interface org.apache.mina.core.service.IoService

      `addListener, broadcast, dispose, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionConfig, getSessionDataStructureFactory, getStatistics, getTransportMetadata, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory`

- - ### Method Detail

    - #### getConnectTimeout

          int getConnectTimeout()

      Deprecated.
      Returns the connect timeout in seconds. The default value is 1 minute.
      See Also:
        `getConnectTimeoutMillis()`

    - #### getConnectTimeoutMillis

          long getConnectTimeoutMillis()

      Returns the connect timeout in milliseconds. The default value is 1 minute.

    - #### setConnectTimeout

          void setConnectTimeout(int connectTimeout)

      Deprecated.
      Sets the connect timeout in seconds. The default value is 1 minute.
      See Also:
        `setConnectTimeoutMillis()`

    - #### setConnectTimeoutMillis

          void setConnectTimeoutMillis(long connectTimeoutInMillis)

      Sets the connect timeout in milliseconds. The default value is 1 minute.

    - #### getDefaultRemoteAddress

          SocketAddress getDefaultRemoteAddress()

      Returns the default remote address to connect to when no argument is specified in `connect()` method.

    - #### setDefaultRemoteAddress

          void setDefaultRemoteAddress(SocketAddress defaultRemoteAddress)

      Sets the default remote address to connect to when no argument is specified in `connect()` method.

    - #### connect

          ConnectFuture connect()

      Connects to the `default remote address`.
      Throws:
        `IllegalStateException` - if no default remoted address is set.

    - #### connect

          ConnectFuture connect(IoSessionInitializer<? extends ConnectFuture> sessionInitializer)

      Connects to the `default remote address` and invokes the `ioSessionInitializer` when the IoSession is created but before `IoHandler.sessionCreated(IoSession)` is invoked. There is no guarantee that the `ioSessionInitializer` will be invoked before this method returns.
      Parameters:
        `sessionInitializer` - the callback to invoke when the `IoSession` object is created
      Throws:
        `IllegalStateException` - if no default remote address is set.

    - #### connect

          ConnectFuture connect(SocketAddress remoteAddress)

      Connects to the specified remote address.
      Returns:
        the `ConnectFuture` instance which is completed when the connection attempt initiated by this call succeeds or fails.

    - #### connect

          ConnectFuture connect(SocketAddress remoteAddress,
                              IoSessionInitializer<? extends ConnectFuture> sessionInitializer)

      Connects to the specified remote address and invokes the `ioSessionInitializer` when the IoSession is created but before `IoHandler.sessionCreated(IoSession)` is invoked. There is no guarantee that the `ioSessionInitializer` will be invoked before this method returns.
      Parameters:
        `remoteAddress` - the remote address to connect to
        `sessionInitializer` - the callback to invoke when the `IoSession` object is created
      Returns:
        the `ConnectFuture` instance which is completed when the connection attempt initiated by this call succeeds or fails.

    - #### connect

          ConnectFuture connect(SocketAddress remoteAddress,
                              SocketAddress localAddress)

      Connects to the specified remote address binding to the specified local address.
      Returns:
        the `ConnectFuture` instance which is completed when the connection attempt initiated by this call succeeds or fails.

    - #### connect

          ConnectFuture connect(SocketAddress remoteAddress,
                              SocketAddress localAddress,
                              IoSessionInitializer<? extends ConnectFuture> sessionInitializer)

      Connects to the specified remote address binding to the specified local address and and invokes the `ioSessionInitializer` when the IoSession is created but before `IoHandler.sessionCreated(IoSession)` is invoked. There is no guarantee that the `ioSessionInitializer` will be invoked before this method returns.
      Parameters:
        `remoteAddress` - the remote address to connect to
        `localAddress` - the local interface to bind to
        `sessionInitializer` - the callback to invoke when the `IoSession` object is created
      Returns:
        the `ConnectFuture` instance which is completed when the connection attempt initiated by this call succeeds or fails.

Copyright © 2004-2012 Apache MINA Project. All Rights Reserved.