private final synchronized void connect(){
  if (socket == null) {
    String host=null;
    String port=null;
    boolean ok=false;
    if (EngineUtil.isNetEngine(fileName)) {
      try {
        String[] lines=Util.readFile(fileName);
        if (lines.length >= 3) {
          host=lines[1];
          port=lines[2];
          ok=true;
        }
      }
 catch (      IOException e1) {
      }
    }
    if (!ok) {
      isError=true;
      report.reportError(context.getString(R.string.network_engine_config_error));
    }
 else {
      try {
        int portNr=Integer.parseInt(port);
        socket=new Socket(host,portNr);
        socket.setTcpNoDelay(true);
      }
 catch (      UnknownHostException e) {
        isError=true;
        report.reportError(e.getMessage());
      }
catch (      NumberFormatException nfe) {
        isError=true;
        report.reportError(context.getString(R.string.invalid_network_port));
      }
catch (      IOException e) {
        isError=true;
        report.reportError(e.getMessage());
      }
    }
    if (socket == null)     socket=new Socket();
  }
}

private final synchronized void connect ( ) { if ( socket == null ) { String host = null ; String port = null ; boolean ok = false ; if ( EngineUtil . isNetEngine ( fileName ) ) { try { String [ ] lines = Util . readFile ( fileName ) ; if ( lines . length >= 3 ) { host = lines [ 1 ] ; port = lines [ 2 ] ; ok = true ; } } catch ( IOException e1 ) { } } if ( ! ok ) { isError = true ; report . reportError ( context . getString ( R . string . network_engine_config_error ) ) ; } else { try { int portNr = Integer . parseInt ( port ) ; socket = new Socket ( host , portNr ) ; socket . setTcpNoDelay ( true ) ; } catch ( UnknownHostException e ) { isError = true ; report . reportError ( e . getMessage ( ) ) ; } catch ( NumberFormatException nfe ) { isError = true ; report . reportError ( context . getString ( R . string . invalid_network_port ) ) ; } catch ( IOException e ) { isError = true ; report . reportError ( e . getMessage ( ) ) ; } } if ( socket == null ) socket = new Socket ( ) ; } }
create socket connection to remote server .
