int upscli_connect(UPSCONN_t *ups, const char *host, int port, int flags);
.fi
.SH"DESCRIPTION"
.sp
The \fBupscli_connect()\fR function takes the pointer \fIups\fR to a UPSCONN_t state structure and opens a TCP connection to the \fIhost\fR on the given \fIport\fR\&.
.sp
\fIflags\fR may be either UPSCLI_CONN_TRYSSL to try a SSL connection, or UPSCLI_CONN_REQSSL to require a SSL connection\&.
.sp
If SSL mode is required, this function will only return successfully if it is able to establish a SSL connection with the server\&. Possible reasons for failure include no SSL support on the server, and if \fBupsclient\fR itself hasn\(cqt been compiled with SSL support\&.
.sp
You must call \fBupscli_disconnect\fR(3) when finished with a connection, or your program will slowly leak memory and file descriptors\&.
.SH"RETURN VALUE"
.sp
The \fBupscli_connect()\fR function modifies the UPSCONN_t structure and returns 0 on success, or \-1 if an error occurs\&.