---
name: "sd_bus_get_n_queued_write"
section: "3"
platform: "linux"
package: "libsystemd-dev"
version: "257.13-1~deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/sd_bus_get_n_queued_read"
---

# sd\_bus\_get\_n\_queued\_write(3)

Get the number of pending bus messages in the read and write queues of a bus connection object

Part of [sd\_bus\_get\_n\_queued\_read(3)](/sd_bus_get_n_queued_read/3.md).

## NAME

sd\_bus\_get\_n\_queued\_read, sd\_bus\_get\_n\_queued\_write - Get the number of pending bus messages in the read and write queues of a bus connection object

## SYNOPSIS

```
#include <systemd/sd-bus.h>
```

**int sd\_bus\_get\_n\_queued\_read(sd\_bus \****bus***, uint64\_t \****ret***);**

**int sd\_bus\_get\_n\_queued\_write(sd\_bus \****bus***, uint64\_t \****ret***);**

## DESCRIPTION

**sd\_bus\_get\_n\_queued\_read()** may be used to query the number of bus messages in the read queue of a bus connection object. The read queue contains all messages read from the transport medium (e.g. network socket) but not yet processed locally. The function expects two arguments: the bus object to query, and a pointer to a 64-bit counter variable to write the current queue size to. Use **sd\_bus\_process()** in order to process queued messages, i.e. to reduce the size of the read queue (as well as, in fact, the write queue, see below).

Similarly, **sd\_bus\_get\_n\_queued\_write()** may be used to query the number of currently pending bus messages in the write queue of a bus connection object. The write queue contains all messages enqueued into the connection with a call such as **sd\_bus\_send()** but not yet written to the transport medium. The expected arguments are similar to **sd\_bus\_get\_n\_queued\_read()**. Here too, use **sd\_bus\_process()** to reduce the size of the write queue. Alternatively, use **sd\_bus\_flush()** to synchronously write out any pending bus messages until the write queue is empty.

## RETURN VALUE

On success, these functions return 0 or a positive integer. On failure, they return a negative errno-style error code.

### Errors

Returned errors may indicate the following problems:

**-ECHILD**

The bus connection was created in a different process, library or module instance.

## HISTORY

**sd\_bus\_get\_n\_queued\_read()** and **sd\_bus\_get\_n\_queued\_write()** were added in version 238.

## SEE ALSO

[**systemd**(1)](/systemd/1.md), [**sd-bus**(3)](/sd-bus/3.md), [**sd\_bus\_process**(3)](/sd_bus_process/3.md), [**sd\_bus\_send**(3)](/sd_bus_send/3.md), [**sd\_bus\_flush**(3)](/sd_bus_flush/3.md)
