Interface IoConnector

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

public interface IoConnector extends IoService
Connects to endpoint, communicates with the server, and fires events to IoHandlers.

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.

  • Method Details

    • getConnectTimeout

      @Deprecated int getConnectTimeout()
      Deprecated.
      Returns:
      the connect timeout in seconds. The default value is 1 minute.
    • getConnectTimeoutMillis

      long getConnectTimeoutMillis()
      Returns:
      the connect timeout in milliseconds. The default value is 1 minute.
    • setConnectTimeout

      @Deprecated void setConnectTimeout(int connectTimeout)
      Deprecated.
      Sets the connect timeout in seconds. The default value is 1 minute.
      Parameters:
      connectTimeout - The time out for the connection
    • setConnectTimeoutMillis

      void setConnectTimeoutMillis(long connectTimeoutInMillis)
      Sets the connect timeout in milliseconds. The default value is 1 minute.
      Parameters:
      connectTimeoutInMillis - The time out for the connection
    • 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.
      Parameters:
      defaultRemoteAddress - The default remote address
    • getDefaultLocalAddress

      SocketAddress getDefaultLocalAddress()
      Returns:
      the default local address
    • setDefaultLocalAddress

      void setDefaultLocalAddress(SocketAddress defaultLocalAddress)
      Sets the default local address
      Parameters:
      defaultLocalAddress - The default local address
    • connect

      ConnectFuture connect()
      Connects to the default remote address.
      Returns:
      the ConnectFuture instance which is completed when the connection attempt initiated by this call succeeds or fails.
      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
      Returns:
      the ConnectFuture instance which is completed when the connection attempt initiated by this call succeeds or fails.
      Throws:
      IllegalStateException - if no default remote address is set.
    • connect

      ConnectFuture connect(SocketAddress remoteAddress)
      Connects to the specified remote address.
      Parameters:
      remoteAddress - The remote address to connect to
      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.
      Parameters:
      remoteAddress - The remote address to connect
      localAddress - The local address to bind
      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.