---
name: "nutclient_tcp_set_timeout"
section: "3"
platform: "linux"
package: "libnutclient-dev"
version: "2.8.1-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/libnutclient_tcp"
---

# nutclient\_tcp\_set\_timeout(3)

TCP protocol related function for Network UPS Tools high-level client access library

Part of [libnutclient\_tcp(3)](/libnutclient_tcp/3.md).

## NAME

libnutclient\_tcp, nutclient\_tcp\_create\_client, nutclient\_tcp\_is\_connected, nutclient\_tcp\_disconnect, nutclient\_tcp\_reconnect, nutclient\_tcp\_set\_timeout, nutclient\_tcp\_get\_timeout - TCP protocol related function for Network UPS Tools high-level client access library

## SYNOPSIS

```
#include <nutclient.h>
#include <cstdint> /* uint16_t */
#include <ctime> /* time_t */
```

```
typedef NUTCLIENT_t NUTCLIENT_TCP_t;
```

```
NUTCLIENT_TCP_t nutclient_tcp_create_client(
        const char* host, uint16_t port);
```

```
int nutclient_tcp_is_connected(NUTCLIENT_TCP_t client);
```

```
void nutclient_tcp_disconnect(NUTCLIENT_TCP_t client);
```

```
int nutclient_tcp_reconnect(NUTCLIENT_TCP_t client);
```

```
void nutclient_tcp_set_timeout(NUTCLIENT_TCP_t client, time_t timeout);
```

```
time_t nutclient_tcp_get_timeout(NUTCLIENT_TCP_t client);
```

## DESCRIPTION

These functions allow to manage connections to [**upsd**(8)](/upsd/8.md) using NUT TCP protocol.

The **nutclient\_tcp\_create\_client()** function create the *NUTCLIENT\_TCP\_t* context and intend to connect to upsd at *host* and *port*. The context must be freed by *nutclient\_destroy()*

• *host* can be a sever name or a valid IPv4 or IPv6 address like "localhost", "127.0.0.1" or "::1".

• *port* is a valid TCP port, generally 3493.

The **nutclient\_tcp\_is\_connected()** function test if the connection is valid.

The **nutclient\_tcp\_disconnect()** function force to disconnect the specified connection.

The **nutclient\_tcp\_reconnect()** function force to reconnect a connection, disconnecting it if needed.

The **nutclient\_tcp\_set\_timeout()** function set the timeout duration for I/O operations.

The **nutclient\_tcp\_get\_timeout()** function retrieve the timeout duration for I/O operations.

*timeout* values are specified in seconds, negatives values for blocking.

## SEE ALSO

[**libnutclient**(3)](/libnutclient/3.md) [**libnutclient\_general**(3)](/libnutclient_general/3.md)
