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 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.

Author:
Apache MINA Project

Method Summary
 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(java.net.SocketAddress remoteAddress)
          Connects to the specified remote address.
 ConnectFuture connect(java.net.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(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
          Connects to the specified remote address binding to the specified local address.
 ConnectFuture connect(java.net.SocketAddress remoteAddress, java.net.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.
 java.net.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(java.net.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

java.net.SocketAddress getDefaultRemoteAddress()
Returns the default remote address to connect to when no argument is specified in connect() method.


setDefaultRemoteAddress

void setDefaultRemoteAddress(java.net.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:
java.lang.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:
java.lang.IllegalStateException - if no default remote address is set.

connect

ConnectFuture connect(java.net.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(java.net.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(java.net.SocketAddress remoteAddress,
                      java.net.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(java.net.SocketAddress remoteAddress,
                      java.net.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-2011 Apache MINA Project. All Rights Reserved.