long clock_check(long now){
  if (m_shutdown == EnShutdown.SD_FORCEFUL) {
    return -1;
  }
  long nTimeout;
  long snd_buffered;
  snd_buffered=m_sbuf.getBuffered();
  if ((m_shutdown == EnShutdown.SD_GRACEFUL) && ((m_state != PseudoTcpState.TCP_ESTABLISHED) || ((snd_buffered == 0) && (m_t_ack == 0)))) {
    return -1;
  }
  if (m_state == PseudoTcpState.TCP_CLOSED) {
    return CLOSED_TIMEOUT;
  }
  nTimeout=DEFAULT_TIMEOUT;
  if (m_t_ack > 0) {
    nTimeout=Math.min(nTimeout,timeDiff(m_t_ack + m_ack_delay,now));
  }
  if (m_rto_base > 0) {
    nTimeout=Math.min(nTimeout,timeDiff(m_rto_base + m_rx_rto,now));
  }
  if (getM_snd_wnd() == 0) {
    nTimeout=Math.min(nTimeout,timeDiff(m_lastsend + m_rx_rto,now));
  }
  if (PSEUDO_KEEPALIVE) {
    if (m_state == PseudoTcpState.TCP_ESTABLISHED) {
      nTimeout=Math.min(nTimeout,timeDiff(m_lasttraffic + (m_bOutgoing ? IDLE_PING * 3 / 2 : IDLE_PING),now));
    }
  }
  return nTimeout <= 0 ? 1 : nTimeout;
}

long clock_check ( long now ) { if ( m_shutdown == EnShutdown . SD_FORCEFUL ) { return - 1 ; } long nTimeout ; long snd_buffered ; snd_buffered = m_sbuf . getBuffered ( ) ; if ( ( m_shutdown == EnShutdown . SD_GRACEFUL ) && ( ( m_state != PseudoTcpState . TCP_ESTABLISHED ) || ( ( snd_buffered == 0 ) && ( m_t_ack == 0 ) ) ) ) { return - 1 ; } if ( m_state == PseudoTcpState . TCP_CLOSED ) { return CLOSED_TIMEOUT ; } nTimeout = DEFAULT_TIMEOUT ; if ( m_t_ack > 0 ) { nTimeout = Math . min ( nTimeout , timeDiff ( m_t_ack + m_ack_delay , now ) ) ; } if ( m_rto_base > 0 ) { nTimeout = Math . min ( nTimeout , timeDiff ( m_rto_base + m_rx_rto , now ) ) ; } if ( getM_snd_wnd ( ) == 0 ) { nTimeout = Math . min ( nTimeout , timeDiff ( m_lastsend + m_rx_rto , now ) ) ; } if ( PSEUDO_KEEPALIVE ) { if ( m_state == PseudoTcpState . TCP_ESTABLISHED ) { nTimeout = Math . min ( nTimeout , timeDiff ( m_lasttraffic + ( m_bOutgoing ? IDLE_PING * 3 / 2 : IDLE_PING ) , now ) ) ; } } return nTimeout <= 0 ? 1 : nTimeout ; }
calculates timeout in ms for current operation
