File: upscli_init_default_connect_timeout.3

package info (click to toggle)
nut 2.8.4%2Breally-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,720 kB
  • sloc: ansic: 132,030; sh: 17,256; cpp: 12,566; makefile: 5,646; python: 1,114; perl: 856; xml: 47
file content (124 lines) | stat: -rw-r--r-- 4,578 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
'\" t
.\"     Title: upscli_init_default_connect_timeout
.\"    Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\"      Date: 08/08/2025
.\"    Manual: NUT Manual
.\"    Source: Network UPS Tools 2.8.4
.\"  Language: English
.\"
.TH "UPSCLI_INIT_DEFAULT_" "3" "08/08/2025" "Network UPS Tools 2\&.8\&.4" "NUT Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
upscli_init_default_connect_timeout \- Initialize upsclient module aspect of default timeout for initial connections\&.
.SH "SYNOPSIS"
.sp
.nf
        #include <upsclient\&.h>

        int upscli_init_default_connect_timeout(
                const char *cli_secs,
                const char *config_secs,
                const char *default_secs);
.fi
.SH "DESCRIPTION"
.sp
The \fBupscli_init_default_connect_timeout()\fR function initializes upsclient module aspect of default connection timeout for \fBupscli_connect\fR(3), which may be important when e\&.g\&. \fBupsc\fR(8) scripting or \fBupsmon\fR(8) configuration refers to unresponsive hosts, or when the host name resolution lags, etc\&. By default, \fBupscli_connect\fR(3) blocks indefinitely in its attempts to connect (or until the system transport layer interrupts such an attempt)\&.
.sp
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):
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
built\-in
\fI0\fR
meaning indefinitely blocking (NUT default for this method over at least 20 years);
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
the number from
default_secs
as a particular NUT or third\-party client program\(cqs built\-in preferred (low\-priority) default;
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
the number from
NUT_DEFAULT_CONNECT_TIMEOUT
environment variable as a site\-local preference (generally pre\-set in
\fBnut.conf\fR(5));
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
the number from
config_secs
as a particular NUT or third\-party client program\(cqs configuration file default;
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
the number from
cli_secs
as a particular NUT or third\-party client program\(cqs setting from command line (highest priority)\&.
.RE
.sp
Internally, calls \fBupscli_set_default_connect_timeout\fR(3) for most of the string related processing\&.
.sp
The upsclient module tracks if \fBupscli_init_default_connect_timeout()\fR function was called and succeeded, in order to call it once (if never used) from the \fBupscli_connect\fR(3) or \fBupscli_init\fR(3) methods\&. This allows unmodified (legacy) NUT clients to consistently benefit from presence of the NUT_DEFAULT_CONNECT_TIMEOUT environment variable\&.
.sp
This tracking does not preclude programs from explicitly calling the method any amount of times\&.
.SH "RETURN VALUE"
.sp
The \fBupscli_init_default_connect_timeout()\fR function returns \fI0\fR 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 \fI\-1\fR if an error occurs (at least one string was not NULL, and none of the strings was valid)\&.
.SH "SEE ALSO"
.sp
\fBupscli_connect\fR(3), \fBupscli_tryconnect\fR(3), \fBupscli_set_default_connect_timeout\fR(3), \fBupscli_get_default_connect_timeout\fR(3), \fBupscli_init\fR(3)