Auto-discover a tradfri gateway on the network.
@param timeout (optional) Time in milliseconds to wait for a response. Default 10000.
Pass false or a negative number to explicitly wait forever.
774984
function discoverGateway(timeout = 10000) {
    const mdns = createMDNSServer({
        reuseAddr: true,
        loopback: false,
        noInit: true,
    });
    let timer;
    const domain = "_coap._udp.local";
    return new Promise((resolve, reject) => {
        mdns.on("response", (resp) => {
            const allAnswers = [...resp.answers, ...resp.additionals];
            const discard = allAnswers.find(a => a.name === domain) == null;
            if (discard)
                return;
            // ensure all record types were received
            const ptrRecord = allAnswers.find(a => a.type === "PTR");
            if (!ptrRecord)
                return;
            const srvRecord = allAnswers.find(a => a.type === "SRV");
            if (!srvRecord)
                return;
            const txtRecord = allAnswers.find(a => a.type === "TXT");
            if (!txtRecord)
                return;
            const aRecords = allAnswers.filter(a => a.type === "A" || a.type === "AAAA");
            if (aRecords.length === 0)
                return;
            // extract the data
            const match = /^gw\-[0-9a-f]{12}/.exec(ptrRecord.data);
            const name = !!match ? match[0] : "unknown";
            const host = srvRecord.data.target;
            const { version } = parseTXTRecord(txtRecord.data);
            const addresses = aRecords.map(a => a.data);
            clearTimeout(timer);
            mdns.destroy();
            resolve({
                name, host, version, addresses,
            });
        });
        mdns.on("ready", () => {
            mdns.query([
                { name: domain, type: "A" },
                { name: domain, type: "AAAA" },
                { name: domain, type: "PTR" },
                { name: domain, type: "SRV" },
                { name: domain, type: "TXT" },
            ]);
        });
        mdns.on("error", reject);
        mdns.initServer();
        if (typeof timeout === "number" && timeout > 0) {
            timer = setTimeout(() => {
                mdns.destroy();
                resolve(null);
            }, timeout);
        }
    });
}
1231425
def timeout(self, timeout=None):
        
        if timeout is None:
            return self.__timeout
        if 0 < float(timeout) < 3600:
            self.__timeout = float(timeout)
            return self.__timeout
        else:
            return None
543032
public void setConnectTimeout(int connectTimeout) {
		this.client = this.client.newBuilder()
				.connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
				.build();
	}
612247
public static Timeout max(Timeout... timeouts)
	{
		Timeout max = null;

		for (Timeout timeout : timeouts)
		{
			if (timeout != null)
				if (max == null || max.getMilliseconds() < timeout.getMilliseconds())
					max = timeout;
		}

		if (max != null)
			return max;
		else
			throw new IllegalArgumentException("Must specify at least one non-null timeout!");
	}
1038192
static void initSelectTimeout() {
        String currentTimeout = System.getProperty(PROPERTY_NETTY_SELECT_TIMEOUT);
        if (currentTimeout == null || "".equals(currentTimeout)) {
            try {
                System.setProperty(PROPERTY_NETTY_SELECT_TIMEOUT, Long.toString(DEFAULT_SELECT_TIMEOUT_MILLIS));
            }
            catch (SecurityException e) {
                if (logger.isWarnEnabled()) {
                    logger.warn(String.format(
                            "Unable to set System property \"%s\" to %d due to %s, Gateway performance may be reduced",
                            PROPERTY_NETTY_SELECT_TIMEOUT, DEFAULT_SELECT_TIMEOUT_MILLIS, e));
                }
            }
        }
    }
1189171
def awaitTermination(self, timeout=None):
        
        if timeout is None:
            self._jssc.awaitTermination()
        else:
            self._jssc.awaitTerminationOrTimeout(int(timeout * 1000))
408731
public synchronized void timeoutTransaction(boolean initial) {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "timeoutTransaction", initial);

        if (tc.isEventEnabled())
            Tr.event(tc, "(SPI) Transaction TIMEOUT occurred for TX: " + getLocalTID());

        _timedOut = true; // mark
        _rollbackOnly = true; // for the case of server quiesce?

        // inactivity timeout may have happened ... check status
        if (_status.getState() == TransactionState.STATE_ACTIVE) {
            // If there is no txn timeout, or we are into completion phase the timeout setting may be zero
            if (_timeout == 0)
                _timeout = 10;
            TimeoutManager.setTimeout(this, TimeoutManager.REPEAT_TIMEOUT, _timeout);
        }

        // Story 132693: JDBC4.1 allows connections to be aborted. Only call abort on the initial
        // call, not on retries.
        if (initial)
            abortTransactionParticipants();

        if (tc.isEntryEnabled())
            Tr.exit(tc, "timeoutTransaction");
    }
994552
public void processTimeout(TimeoutEvent timeoutEvent) {
				
		final SIPTransaction t;
		if (timeoutEvent.isServerTransaction()) {
			t = (SIPTransaction) timeoutEvent.getServerTransaction();
		}
		else {
			t = (SIPTransaction) timeoutEvent.getClientTransaction();
		}
		
		if (tracer.isInfoEnabled()) {
			tracer.info("Transaction "
						+ t.getTransactionId()
						+ " timer expired");			
		}
		
		TransactionWrapper tw = getTransactionWrapper(t);
		if (tw == null) {
			if (tracer.isInfoEnabled()) {
				tracer.info("Received timeout event for tx "+t.getTransactionId()+" with null app data, dropping...");
			}
			return;
		}
		
		final TimeoutEventWrapper tew;
		if (timeoutEvent.isServerTransaction()) {
			tew = new TimeoutEventWrapper(providerWrapper,(ServerTransaction)tw, timeoutEvent.getTimeout());
		}
		else {
			tew = new TimeoutEventWrapper(providerWrapper,(ClientTransaction)tw, timeoutEvent.getTimeout());
		}

        final Dialog d = t.getDialog();
		final DialogWrapper dw = getDialogWrapper(d);
		final FireableEventType eventType = eventIdCache.getTransactionTimeoutEventId(
				eventLookupFacility, dw != null);
		if (!eventIDFilter.filterEvent(eventType)) {
			Wrapper activity = tw.isActivity() ? tw : dw;			
			try {
				fireEvent(activity.getActivityHandle(), eventType, tew, activity.getEventFiringAddress(),DEFAULT_EVENT_FLAGS);
			}
			catch (UnrecognizedActivityHandleException e) {
				tracer.warning("Failed to fire event "+eventType+", the activity "+activity+" does not exists in the SLEE");			
			}
			catch (Throwable e) {
				tracer.severe("Failed to fire event",e);
			}
		}
		else {
			if (tracer.isFineEnabled()) {
				tracer.fine("Event "+eventType+" filtered.");
			}
		}
        if (d != null && dw != null && (d.getState() == null || d.getState() == DialogState.TERMINATED)) {
            // Issue 98: sip stack won't invoke processDialogTerminate when dialog creating tx times out
            processDialogTerminated(dw);
        }
	}
308637
@SuppressWarnings("deprecation")
	private void setLegacySocketTimeout(HttpClient client, int timeout) {
		if (org.apache.http.impl.client.AbstractHttpClient.class.isInstance(client)) {
			client.getParams().setIntParameter(
					org.apache.http.params.CoreConnectionPNames.SO_TIMEOUT, timeout);
		}
	}
592637
public void setResponseTimeout(int timeout) {
        try {
            getConnection().setReadTimeout(timeout);
        } catch (Exception e) {
            Modbus.log().warning(e.getLocalizedMessage());
        }
    }
188459
public void processDialogTimeout(final DialogTimeoutEvent timeoutEvent) {
		final Dialog dialog = timeoutEvent.getDialog();
		if(logger.isDebugEnabled()) {
			logger.info("dialog timeout " + dialog + " reason => " + timeoutEvent.getReason());
		}
		if(timeoutEvent.getReason() == Reason.AckNotReceived) {
			final TransactionApplicationData tad = (TransactionApplicationData) dialog.getApplicationData();
			if(tad != null && tad.getSipServletMessage() != null) {
				// https://github.com/RestComm/sip-servlets/issues/107 guard against NPEon concurrent cleanup
				final SipServletMessageImpl sipServletMessage = tad.getSipServletMessage();
				final MobicentsSipSessionKey sipSessionKey = sipServletMessage.getSipSessionKey();
				final MobicentsSipSession sipSession = sipServletMessage.getSipSession();
				getAsynchronousExecutor().execute(new Runnable() {
					public void run() {
						if(logger.isDebugEnabled()) {
							logger.info("Running process dialog timeout " + dialog + " reason => " + timeoutEvent.getReason());
						}
						try {
							if(sipSession != null) {
								SipContext sipContext = findSipApplication(sipSessionKey.getApplicationName());
								//the context can be null if the server is being shutdown
								if(sipContext != null) {
									MobicentsSipApplicationSession sipApplicationSession = sipSession.getSipApplicationSession();
									try {
										sipContext.enterSipApp(sipApplicationSession, sipSession, false, true);
										checkForAckNotReceived(sipServletMessage);
										checkForPrackNotReceived(sipServletMessage);
									} finally {
										sipContext.exitSipApp(sipApplicationSession, sipSession);
									}
									// Issue 1822 http://code.google.com/p/mobicents/issues/detail?id=1822
									// don't delete the dialog so that the app can send the BYE even after the noAckReceived has been called
									//								dialog.delete();
									tryToInvalidateSession(sipSessionKey, false);
								}
							}
							tad.cleanUp();
							tad.cleanUpMessage();
							dialog.setApplicationData(null);
						} catch (Exception e) {
							logger.error("Problem handling dialog timeout", e);
						}
					}
				});
			} else{
				dialog.setApplicationData(null);
			}
		} else {
			dialog.setApplicationData(null);
		}
	}
1116792
function ConnectionTimeoutError(timeout) {
    Error.call(this);
    Error.captureStackTrace(this, this.constructor);
    this.message = 'connection timed out';

    if (timeout) {
        this.message += '. timeout = ' + timeout + ' ms';
    }

    this.name = 'ConnectionTimeoutError';
}
1028387
def set_timeout(scope, timeout):
    
    conn = scope.get('__connection__')
    conn.set_timeout(int(timeout[0]))
    return True
874187
private void setConnectTimeout(HttpURLConnection connection) {
        try {
            Map<String, String> endpointProperties = this.api.getEndpointProperties();
            if (endpointProperties.containsKey("timeouts.connect")) { //$NON-NLS-1$
                int connectTimeoutMs = new Integer(endpointProperties.get("timeouts.connect")); //$NON-NLS-1$
                connection.setConnectTimeout(connectTimeoutMs);
            }
        } catch (Throwable t) {
        }
    }
448095
public long waiting(long timeout, boolean modifyTimeout)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(this, tc, "waiting", new Object[] { new Long(timeout),  Boolean.valueOf(modifyTimeout) });

    boolean processGets = true;
    synchronized(this)
    {
      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
        SibTr.debug(tc, "refilling: " + Boolean.valueOf(isRefilling) +
                        "doRefill: " + Boolean.valueOf(doRefill));
      if (isRefilling)
      {
        processGets = false;
        
        // A request came in while we were busy doing refills. Therfore we
        // record the timeout (if we dont have a longer one) in case we have to redrive
        // a new refill request when the current one is satisfied.
        if (timeout == LocalConsumerPoint.INFINITE_WAIT)
          refillTime = timeout;
        else if (timeout != LocalConsumerPoint.NO_WAIT)
        {
          // Work out when this request would have expired
          long expiryTime = System.currentTimeMillis() + timeout;
          
          // If we dont have a current refillTime that extends to the period of this request
          // then set the new refillTime
          if (refillTime != LocalConsumerPoint.INFINITE_WAIT && refillTime < expiryTime)
            refillTime = expiryTime;
        }
      }
      else
      {
        if (doRefill) // Has a refill been inititated
        {
          isRefilling = true;
          doRefill = false;
        }
      }        
    }
    
    if (processGets)
    {     
      try
      {
        long protocolTimeout;
        // Either modify the timeout with a roundTrip time or not.
        // But always convert the protocol time into a SIMP format
        // (from the LCP format)
        if (modifyTimeout)
        {
          if (timeout == LocalConsumerPoint.INFINITE_WAIT)
          { // no need to modify timeout
    
            // we are using a different constant for the protocol
            protocolTimeout = SIMPConstants.INFINITE_TIMEOUT;
          }
          else if (timeout == LocalConsumerPoint.NO_WAIT)
          {
            timeout = getRoundTripTime(); // the consumer needs to wait atleast
                                          // for this time
            protocolTimeout = 0L; // this ensures that the DME knows not to wait
          }
          else
          {
            long rtt = getRoundTripTime();
            protocolTimeout = timeout + rtt;
            timeout = protocolTimeout;
          }
        }
        else
        {
          if (timeout == LocalConsumerPoint.INFINITE_WAIT)
            protocolTimeout = SIMPConstants.INFINITE_TIMEOUT;
          else if (timeout == LocalConsumerPoint.NO_WAIT)
            protocolTimeout = 0L; // this ensures that the DME knows not to wait
          else
            protocolTimeout = timeout;
        }
        
        boolean callIssueGet = true;
        if (readAhead || protocolTimeout == SIMPConstants.INFINITE_TIMEOUT)
        {
          synchronized (this)
          {
            if (countOfOutstandingInfiniteTimeoutGets > 0)
            {
              callIssueGet = false; // already scheduled requests
            }
            else
            {
              if (keyGroup == null)
              {
  
                // will issue get, so update counts within the synchronized block
                if (protocolTimeout == SIMPConstants.INFINITE_TIMEOUT)
                {
                  countOfOutstandingInfiniteTimeoutGets++;
  
                  if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                      SibTr.debug(tc, "readAhead change: countOfOutstandingInfiniteTimeoutGets++ " + countOfOutstandingInfiniteTimeoutGets);
                }
              }
              // else do nothing, since gets issued on the key group don't count
              // towards
              // countOfOutstandingInfiniteTimeoutGets
            }
          }
          if (readAhead)
              tryPrefetching(); // call try prefetching since window may have
                                // increased
        }
  
        if (callIssueGet)
        {
          AIStreamKey key;
          if (keyGroup == null)
            key = rcd.issueGet(criteria, protocolTimeout, this, this);
          else
            key = ((RemoteQPConsumerKeyGroup) keyGroup).issueGet(protocolTimeout, this);
         
          if (key == null)
          {
            // decrement the counts. this will be very rare!
            synchronized (this)
            {
              if ((keyGroup == null)
                  && (protocolTimeout == SIMPConstants.INFINITE_TIMEOUT))
              {
                countOfOutstandingInfiniteTimeoutGets--;
                
  
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    SibTr.debug(tc, "readAhead change: countOfOutstandingInfiniteTimeoutGets-- " + countOfOutstandingInfiniteTimeoutGets);
              }
            }
            // log and throw exception to consumer
            SIResourceException e = new SIResourceException(nls
                .getFormattedMessage("ANYCAST_STREAM_UNAVAILABLE_CWSIP0481",
                    new Object[] { rcd.getDestName(),
                        rcd.getLocalisationUuid().toString() }, null));
            FFDCFilter.processException(e,
                "com.ibm.ws.sib.processor.impl.RemoteQPConsumerKey.waiting",
                "1:357:1.47.1.26", this);
            SibTr.exception(tc, e);
  
            consumerPoint.notifyException(e);
          }
        }
      }
      catch (SIResourceException e)
      {
        // FFDC
        FFDCFilter.processException(e,
            "com.ibm.ws.sib.processor.impl.RemoteQPConsumerKey.waiting",
            "1:369:1.47.1.26", this);
  
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
          SibTr.exception(tc, e);
  
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
          SibTr.exit(tc, "waiting", "SIErrorException");
        throw new SIErrorException(e);
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(this, tc, "waiting", Long.valueOf(timeout));

    return timeout;
  }
840292
public ConverterServerBuilder processTimeout(long processTimeout, TimeUnit timeUnit) {
        assertNumericArgument(processTimeout, false);
        this.processTimeout = timeUnit.toMillis(processTimeout);
        return this;
    }
241935
public SdkClientBuilder connectionCheckoutTimeout(long timeout, TimeUnit unit)
    {
        this.connectionCheckoutTimeoutMs = (int) TimeUnit.MILLISECONDS.convert(timeout, unit);
        return this;
    }