code: public void waitFor(Flag aborted, int ioDelay, int maxWait) throws ServerException,
  			IOException, InterruptedException {
  
          int oldTimeout = this.socket.getSoTimeout();
  
          try {
              int c = 0;
              if (maxWait != WAIT_FOREVER) {
                  this.socket.setSoTimeout(maxWait);
              } else {
                  this.socket.setSoTimeout(0);
              }
  
              c = this.checkSocketDone(aborted, ioDelay, maxWait);
  
              /*
                A bug in the server causes it to append \0 to each reply.
                As the result, we receive this \0 before the next reply.
                The code below handles this case.
  
              */
              if (c != 0) {
                  // if we're here, the server is healthy
                  // and the reply is waiting in the buffer
                  return;
              }
  
              // if we're here, we deal with the buggy server.
              // we discarded the \0 and now resume wait.
  
              logger.debug("Server sent \\0; resume wait");
              try {
                  // gotta read past the 0 we just remarked
                  c = ftpIn.read();
                  c = this.checkSocketDone(aborted, ioDelay, maxWait);
              } catch (SocketTimeoutException e) {
                  throw new ServerException(ServerException.REPLY_TIMEOUT);
              } catch (EOFException e) {
                  throw new InterruptedException();
              }
          } finally {
              this.socket.setSoTimeout(oldTimeout);
          }
  	}
docs: Block until one of the conditions are true:
  <ol>
  <li> a reply is available in the control channel,
  <li> timeout (maxWait) expired
  <li> aborted flag changes to true.
  </ol>
  If maxWait == WAIT_FOREVER, never timeout
  and only check conditions (1) and (3).
  @param maxWait timeout in miliseconds
  @param ioDelay frequency of polling the control channel
  and checking the conditions
  @param aborted flag indicating wait aborted.