1UPSCLI_CONNECT(3)                 NUT Manual                 UPSCLI_CONNECT(3)
2
3
4

NAME

6       upscli_connect - Open a connection to a NUT upsd
7

SYNOPSIS

9       #include <upsclient.h>
10
11       int upscli_connect(UPSCONN_t *ups, const char *host, uint16_t port, int flags);
12

DESCRIPTION

14       The upscli_connect() function takes the pointer ups to a UPSCONN_t
15       state structure and opens a TCP connection to the host on the given
16       port.
17
18       flags may be either UPSCLI_CONN_TRYSSL to try a SSL connection, or
19       UPSCLI_CONN_REQSSL to require a SSL connection.
20
21       Introduced in version 2.7, an additional flag UPSCLI_CONN_CERTVERIF now
22       exists to verify the signature offered during the SSL handshake. This
23       flag should be used in conjunction with upscli_init(3) and/or
24       upscli_add_host_cert(3) calls before connecting in order to define a CA
25       certificate with which to verify.
26
27       If SSL mode is required, this function will only return successfully if
28       it is able to establish a SSL connection with the server. Possible
29       reasons for failure include no SSL support on the server, and if
30       upsclient itself hasn’t been compiled with SSL support.
31
32       You must call upscli_disconnect(3) when finished with a connection, or
33       your program will slowly leak memory and file descriptors.
34

RETURN VALUE

36       The upscli_connect() function modifies the UPSCONN_t structure and
37       returns 0 on success, or -1 if an error occurs.
38

SEE ALSO

40       upscli_disconnect(3), upscli_fd(3), upscli_splitaddr(3),
41       upscli_splitname(3), upscli_ssl(3), upscli_strerror(3),
42       upscli_upserror(3)
43
44
45
46Network UPS Tools 2.8.0           04/26/2022                 UPSCLI_CONNECT(3)
Impressum