Package 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 toIoHandler
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
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description ConnectFuture
connect()
Connects to thedefault remote address
.ConnectFuture
connect(SocketAddress remoteAddress)
Connects to the specified remote address.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 theioSessionInitializer
when the IoSession is created but beforeIoHandler.sessionCreated(IoSession)
is invoked.ConnectFuture
connect(SocketAddress remoteAddress, IoSessionInitializer<? extends ConnectFuture> sessionInitializer)
Connects to the specified remote address and invokes theioSessionInitializer
when the IoSession is created but beforeIoHandler.sessionCreated(IoSession)
is invoked.ConnectFuture
connect(IoSessionInitializer<? extends ConnectFuture> sessionInitializer)
Connects to thedefault remote address
and invokes theioSessionInitializer
when the IoSession is created but beforeIoHandler.sessionCreated(IoSession)
is invoked.int
getConnectTimeout()
Deprecated.long
getConnectTimeoutMillis()
SocketAddress
getDefaultLocalAddress()
SocketAddress
getDefaultRemoteAddress()
void
setConnectTimeout(int connectTimeout)
Deprecated.void
setConnectTimeoutMillis(long connectTimeoutInMillis)
Sets the connect timeout in milliseconds.void
setDefaultLocalAddress(SocketAddress defaultLocalAddress)
Sets the default local addressvoid
setDefaultRemoteAddress(SocketAddress defaultRemoteAddress)
Sets the default remote address to connect to when no argument is specified inconnect()
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
@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 inconnect()
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 thedefault 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 thedefault remote address
and invokes theioSessionInitializer
when the IoSession is created but beforeIoHandler.sessionCreated(IoSession)
is invoked. There is no guarantee that theioSessionInitializer
will be invoked before this method returns.- Parameters:
sessionInitializer
- the callback to invoke when theIoSession
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 theioSessionInitializer
when the IoSession is created but beforeIoHandler.sessionCreated(IoSession)
is invoked. There is no guarantee that theioSessionInitializer
will be invoked before this method returns.- Parameters:
remoteAddress
- the remote address to connect tosessionInitializer
- the callback to invoke when theIoSession
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 connectlocalAddress
- 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 theioSessionInitializer
when the IoSession is created but beforeIoHandler.sessionCreated(IoSession)
is invoked. There is no guarantee that theioSessionInitializer
will be invoked before this method returns.- Parameters:
remoteAddress
- the remote address to connect tolocalAddress
- the local interface to bind tosessionInitializer
- the callback to invoke when theIoSession
object is created- Returns:
- the
ConnectFuture
instance which is completed when the connection attempt initiated by this call succeeds or fails.
-
-