---
name: "upscli_fd"
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_fd"
---

# upscli\_fd(3)

Get file descriptor for connection

## NAME

upscli\_fd - Get file descriptor for connection

## SYNOPSIS

```
        #include <upsclient.h>
        int upscli_fd(UPSCONN_t *ups);
```

## DESCRIPTION

The **upscli\_fd()** function takes the pointer *ups* to a UPSCONN\_t state structure and returns the value of the file descriptor for that connection, if any.

This may be useful for determining if the connection to [**upsd**(8)](/upsd/8.md) has been lost.

## RETURN VALUE

The **upscli\_fd()** function returns the file descriptor, which may be any non-negative number.

It returns *-1* if an error occurs.

## SEE ALSO

[**upscli\_connect**(3)](/upscli_connect/3.md), [**upscli\_strerror**(3)](/upscli_strerror/3.md), [**upscli\_upserror**(3)](/upscli_upserror/3.md)
