---
name: "upscli_init_default_connect_timeout"
section: "3"
platform: "linux"
package: "nut"
version: "2.8.5-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/upscli_init_default_connect_timeout"
---

# upscli\_init\_default\_connect\_timeout(3)

Initialize upsclient module aspect of default timeout for initial connections.

## NAME

upscli\_init\_default\_connect\_timeout - Initialize upsclient module aspect of default timeout for initial connections.

## SYNOPSIS

```
        #include <upsclient.h>
        int upscli_init_default_connect_timeout(
                const char *cli_secs,
                const char *config_secs,
                const char *default_secs);
```

## DESCRIPTION

The **upscli\_init\_default\_connect\_timeout()** function initializes upsclient module aspect of default connection timeout for [**upscli\_connect**(3)](/upscli_connect/3.md), which may be important when e.g. [**upsc**(8)](/upsc/8.md) scripting or [**upsmon**(8)](/upsmon/8.md) configuration refers to unresponsive hosts, or when the host name resolution lags, etc. By default, [**upscli\_connect**(3)](/upscli_connect/3.md) blocks indefinitely in its attempts to connect (or until the system transport layer interrupts such an attempt).

It populates the value from different sources, mostly C strings which represent a floating-point non-negative number (invalid parsing is logged and may impact the return value), any or all of them may be NULL to skip, and in specific order (last valid hit wins):

• built-in *0* meaning indefinitely blocking (NUT default for this method over at least 20 years);

• the number from default\_secs as a particular NUT or third-party client program’s built-in preferred (low-priority) default;

• the number from NUT\_DEFAULT\_CONNECT\_TIMEOUT environment variable as a site-local preference (generally pre-set in [**nut.conf**(5)](/nut.conf/5.md));

• the number from config\_secs as a particular NUT or third-party client program’s configuration file default;

• the number from cli\_secs as a particular NUT or third-party client program’s setting from command line (highest priority).

Internally, calls [**upscli\_set\_default\_connect\_timeout**(3)](/upscli_set_default_connect_timeout/3.md) for most of the string related processing.

The upsclient module tracks if **upscli\_init\_default\_connect\_timeout()** function was called and succeeded, in order to call it once (if never used) from the [**upscli\_connect**(3)](/upscli_connect/3.md) or [**upscli\_init**(3)](/upscli_init/3.md) methods. This allows unmodified (legacy) NUT clients to consistently benefit from presence of the NUT\_DEFAULT\_CONNECT\_TIMEOUT environment variable.

This tracking does not preclude programs from explicitly calling the method any amount of times.

## RETURN VALUE

The **upscli\_init\_default\_connect\_timeout()** function returns *0* on success (either if all strings were NULL so the built-in default is applied, or at least one of those strings that were set was valid and its value got applied), or *-1* if an error occurs (at least one string was not NULL, and none of the strings was valid).

## SEE ALSO

[**upscli\_connect**(3)](/upscli_connect/3.md), **upscli\_tryconnect**(3), [**upscli\_set\_default\_connect\_timeout**(3)](/upscli_set_default_connect_timeout/3.md), [**upscli\_get\_default\_connect\_timeout**(3)](/upscli_get_default_connect_timeout/3.md), [**upscli\_init**(3)](/upscli_init/3.md)
