You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by chihiro <ga...@gmail.com> on 2007/10/17 05:05:01 UTC
Implementation of isConnected()
Hi,
I am caching ConnectFuture in my client code and when during the call to
send bytes to the server,
I will test the connection by calling this isConnected() method:
/**
* @return true if we are connected to the remote peer, else false
*/
private final boolean isConnected()
{
IoSession session;
try
{
session = ( m_connectFuture != null ) ? m_connectFuture.getSession()
: null;
} catch( RuntimeIOException e )
{
return false;
}
return( m_connectFuture != null && m_connectFuture.isConnected() &&
session != null && session.isConnected() );
}
If it returns false, I will attempt a reconnection. It is working fine right
now. But I want to know if
there are other alternative solutions. Thanks all.
chihiro
--
View this message in context: http://www.nabble.com/Implementation-of-isConnected%28%29-tf4637998s16868.html#a13246352
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Re: Implementation of isConnected()
Posted by Trustin Lee <tr...@gmail.com>.
On 10/17/07, Trustin Lee <tr...@gmail.com> wrote:
> return connectFuture.isConnected();
>
> Simple, eh? :)
Oops, you want something more complicated. Yours look fine.
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6
Re: Implementation of isConnected()
Posted by Trustin Lee <tr...@gmail.com>.
return connectFuture.isConnected();
Simple, eh? :)
Trustin
On 10/17/07, chihiro <ga...@gmail.com> wrote:
>
> Hi,
>
> I am caching ConnectFuture in my client code and when during the call to
> send bytes to the server,
> I will test the connection by calling this isConnected() method:
>
> /**
> * @return true if we are connected to the remote peer, else false
> */
> private final boolean isConnected()
> {
> IoSession session;
> try
> {
> session = ( m_connectFuture != null ) ? m_connectFuture.getSession()
> : null;
> } catch( RuntimeIOException e )
> {
> return false;
> }
> return( m_connectFuture != null && m_connectFuture.isConnected() &&
> session != null && session.isConnected() );
> }
>
> If it returns false, I will attempt a reconnection. It is working fine right
> now. But I want to know if
> there are other alternative solutions. Thanks all.
>
> chihiro
> --
> View this message in context: http://www.nabble.com/Implementation-of-isConnected%28%29-tf4637998s16868.html#a13246352
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
>
>
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6