---
name: "nng_listener"
section: "5"
platform: "linux"
package: "libnng-dev"
version: "1.10.1-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/nng_listener"
---

# nng\_listener(5)

listener

## NAME

nng\_listener - listener

## SYNOPSIS

```
#include <nng/nng.h>
typedef struct nng_listener_s nng_listener;
```

## DESCRIPTION

An `nng_listener` is a handle to a listener object, which is responsible for creating `nng_pipe` objects by accepting incoming connections. A given listener object may create many pipes at the same time, much like an HTTP server can have many connections to multiple clients simultaneously.

Listener objects are created by the `nng_listener_create()` or `nng_listen()` functions, and are always associated with a single `nng_socket`.

**Important**\

The `nng_listener` structure is always passed by value (both for input parameters and return values), and should be treated opaquely. Passing structures this way gives the compiler a chance to perform accurate type checks in functions passing values of this type.

**Tip**\

A given `nng_socket` may have multiple listener objects, multiple dialer objects, or even some of both.

**Tip**\

The client/server relationship described by dialer/listener is completely orthogonal to any similar relationship in the protocols. For example, a *rep* socket may use a dialer to connect to a listener on an *req* socket. This orthogonality can lead to innovative solutions to otherwise challenging communications problems.

Listener objects may be destroyed by the `nng_listener_close()` function. They are also closed when their associated socket is closed.

### Initialization

A listener may be initialized using the macro `NNG_LISTENER_INITIALIZER` before it is opened, to prevent confusion with valid open listener.

## SEE ALSO

[nng\_listen(3)](/nng_listen/3.md), [nng\_listener\_close(3)](/nng_listener_close/3.md), [nng\_listener\_create(3)](/nng_listener_create/3.md), [nng\_listener\_getopt(3)](/nng_listener_getopt/3.md), [nng\_listener\_id(3)](/nng_listener_id/3.md), [nng\_listener\_setopt(3)](/nng_listener_setopt/3.md), [nng\_listener\_start(3)](/nng_listener_start/3.md), [nng\_dialer(5)](/nng_dialer/5.md), [nng\_pipe(5)](/nng_pipe/5.md), [nng\_socket(5)](/nng_socket/5.md), [nng(7)](/nng/7.md)
