@Override public synchronized void flush() throws IOException {
  logger.log(Level.FINE,"Flushing...");
  long start=System.currentTimeMillis();
  final Object ackNotify=pseudoTcp.getAckNotify();
synchronized (ackNotify) {
    while (pseudoTcp.getBytesBufferedNotSent() > 0) {
      try {
        if (writeTimeout > 0) {
          long elapsed=System.currentTimeMillis() - start;
          long left=writeTimeout - elapsed;
          if (left <= 0) {
            IOException e=new IOException("Flush operation timeout");
            pseudoTcp.closedown(e);
            throw e;
          }
          ackNotify.wait(left);
        }
 else {
          ackNotify.wait();
        }
      }
 catch (      InterruptedException ex) {
        throw new IOException("Flush stream interrupted",ex);
      }
    }
  }
  logger.log(Level.FINE,"Flushing completed");
}

@ Override public synchronized void flush ( ) throws IOException { logger . log ( Level . FINE , "Flushing..." ) ; long start = System . currentTimeMillis ( ) ; final Object ackNotify = pseudoTcp . getAckNotify ( ) ; synchronized ( ackNotify ) { while ( pseudoTcp . getBytesBufferedNotSent ( ) > 0 ) { try { if ( writeTimeout > 0 ) { long elapsed = System . currentTimeMillis ( ) - start ; long left = writeTimeout - elapsed ; if ( left <= 0 ) { IOException e = new IOException ( "Flush operation timeout" ) ; pseudoTcp . closedown ( e ) ; throw e ; } ackNotify . wait ( left ) ; } else { ackNotify . wait ( ) ; } } catch ( InterruptedException ex ) { throw new IOException ( "Flush stream interrupted" , ex ) ; } } } logger . log ( Level . FINE , "Flushing completed" ) ; }
this method block until all buffered data has been written
