code: public EventObject waitResponse(SipTransaction trans, long timeout) {
      // TODO later: waitResponse() for nontransactional-request case
  
      initErrorInfo();
  
      synchronized (trans.getBlock()) {
        LinkedList<EventObject> events = trans.getEvents();
        if (events.isEmpty()) {
          try {
            trans.getBlock().waitForEvent(timeout);
          } catch (Exception ex) {
            setException(ex);
            setErrorMessage("Exception: " + ex.getClass().getName() + ": " + ex.getMessage());
            setReturnCode(EXCEPTION_ENCOUNTERED);
            return null;
          }
        }
  
        if (events.isEmpty()) {
          setReturnCode(TIMEOUT_OCCURRED);
          setErrorMessage("The maximum amount of time to wait for a response message has elapsed.");
          return null;
        }
  
        return (EventObject) events.removeFirst();
      }
    }
docs: The waitResponse() method waits for a response to a previously sent transactional request
  message. Call this method after using one of the sendRequestWithTransaction() methods.
  
  This method blocks until one of the following occurs: 1) A javax.sip.ResponseEvent is received.
  This is the object returned by this method. 2) A javax.sip.TimeoutEvent is received. This is
  the object returned by this method. 3) The wait timeout period specified by the parameter to
  this method expires. Null is returned in this case. 4) An error occurs. Null is returned in
  this case.
  
  Note that this method can be called repeatedly upon receipt of provisional response message(s).
  
  @param trans The SipTransaction object associated with the sent request.
  @param timeout The maximum amount of time to wait, in milliseconds. Use a value of 0 to wait
  indefinitely.
  @return A javax.sip.ResponseEvent, javax.sip.TimeoutEvent, or null in the case of wait timeout
  or error. If null, call getReturnCode() and/or getErrorMessage() and, if applicable,
  getException() for further diagnostics.