public LoginServerConnection connect(){
  SocketChannel sc;
  for (; ; ) {
    loginServer=null;
    log.info("Connecting to LoginServer: " + NetworkConfig.LOGIN_ADDRESS);
    try {
      sc=SocketChannel.open(NetworkConfig.LOGIN_ADDRESS);
      sc.configureBlocking(false);
      Dispatcher d=nioServer.getReadWriteDispatcher();
      loginServer=new LoginServerConnection(sc,d);
      d.register(sc,SelectionKey.OP_READ,loginServer);
      loginServer.initialized();
      return loginServer;
    }
 catch (    Exception e) {
      log.info("Cant connect to LoginServer: " + e.getMessage());
    }
    try {
      Thread.sleep(10 * 1000);
    }
 catch (    Exception e) {
    }
  }
}

public LoginServerConnection connect ( ) { SocketChannel sc ; for ( ; ; ) { loginServer = null ; log . info ( "Connecting to LoginServer: " + NetworkConfig . LOGIN_ADDRESS ) ; try { sc = SocketChannel . open ( NetworkConfig . LOGIN_ADDRESS ) ; sc . configureBlocking ( false ) ; Dispatcher d = nioServer . getReadWriteDispatcher ( ) ; loginServer = new LoginServerConnection ( sc , d ) ; d . register ( sc , SelectionKey . OP_READ , loginServer ) ; loginServer . initialized ( ) ; return loginServer ; } catch ( Exception e ) { log . info ( "Cant connect to LoginServer: " + e . getMessage ( ) ) ; } try { Thread . sleep ( 10 * 1000 ) ; } catch ( Exception e ) { } } }
connect to loginserver and return object representing this connection . this method is blocking and may block till connect successful .
