directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Samuel Doyle <sdoyl...@yahoo.com>
Subject [mina] Can you use the same SessionHandler multiple times??
Date Wed, 01 Feb 2006 03:54:35 GMT
If I'm opening up multiple persistent connections to
say two hosts can I use the same session handler
multiple times or do I need to create a new instance.
For example:

 InetSocketAddress host_1 = 
         new InetSocketAddress( "xxx.xx.xx.xxx", xxxxx
);
      IoSession session = null;
      MYSessionHandler sessionHandler = null;
      
      for( int i = 0; i < 2; i++ )
      {
         sessionHandler = 
            new MYSessionHandler( );
         try
         {
            ConnectFuture future =
               connector.connect(host_1,
sessionHandler );
            
            future.join();
            
            // This session is what we use to write to
legacy server.
            session = future.getSession();
         }
         catch( IOException e )
         {
            System.err.println( "Failed to connect."
);
            e.printStackTrace();
            // Failed this session try again.
            continue;
         }
         
         // Track the session.
         this.sessionTracker.addElement( session );
      }

Do I need to keep doing 
   sessionHandler = new MYSessionHandler( );
within the loop or just doing it once outside is fine?

Thanks, S.D.

Mime
View raw message