private boolean captureFromSocket(String host,int port,@NotNull Options options) throws IOException, InterruptedException {
  myListener.onAction("Connecting to application...");
  Socket socket=null;
  long lastUpdateMS=0;
  long total=0;
  byte[] buffer=new byte[4096];
  int retriesLeft=60;
  try {
    int len=0;
    while (!myStopped) {
      if (socket == null) {
        socket=new Socket(host,port);
        socket.setSoTimeout(500);
        sendHeader(socket,options);
      }
      try {
        len=copyBlock(socket,myCapture,buffer);
      }
 catch (      IOException ex) {
        if (total == 0 && retriesLeft > 0) {
          len=-1;
        }
 else {
          throw ex;
        }
      }
      if (len > 0) {
        if (total == 0) {
          myListener.onAction("Tracing...");
        }
        total+=len;
        long nowMS=System.currentTimeMillis();
        if (nowMS - lastUpdateMS > UPDATE_FREQUENCY_MS) {
          myListener.onProgress(total);
          lastUpdateMS=nowMS;
        }
      }
 else       if (len < 0) {
        socket.close();
        socket=null;
        if (total == 0 && retriesLeft-- > 0) {
          Thread.sleep(500);
        }
 else {
          stop();
        }
      }
    }
  }
  finally {
    if (socket != null) {
      socket.close();
    }
  }
  return total > 0;
}

private boolean captureFromSocket ( String host , int port , @ NotNull Options options ) throws IOException , InterruptedException { myListener . onAction ( "Connecting to application..." ) ; Socket socket = null ; long lastUpdateMS = 0 ; long total = 0 ; byte [ ] buffer = new byte [ 4096 ] ; int retriesLeft = 60 ; try { int len = 0 ; while ( ! myStopped ) { if ( socket == null ) { socket = new Socket ( host , port ) ; socket . setSoTimeout ( 500 ) ; sendHeader ( socket , options ) ; } try { len = copyBlock ( socket , myCapture , buffer ) ; } catch ( IOException ex ) { if ( total == 0 && retriesLeft > 0 ) { len = - 1 ; } else { throw ex ; } } if ( len > 0 ) { if ( total == 0 ) { myListener . onAction ( "Tracing..." ) ; } total += len ; long nowMS = System . currentTimeMillis ( ) ; if ( nowMS - lastUpdateMS > UPDATE_FREQUENCY_MS ) { myListener . onProgress ( total ) ; lastUpdateMS = nowMS ; } } else if ( len < 0 ) { socket . close ( ) ; socket = null ; if ( total == 0 && retriesLeft -- > 0 ) { Thread . sleep ( 500 ) ; } else { stop ( ) ; } } } } finally { if ( socket != null ) { socket . close ( ) ; } } return total > 0 ; }
capturefromsocket attempts to connect to graphics interceptor on the specified address .
