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

# nng\_listener\_create(3)

create listener

## NAME

nng\_listener\_create - create listener

## SYNOPSIS

```
#include <nng/nng.h>
int nng_listener_create(nng_listener *listenerp, nng_socket s, const char *url);
```

## DESCRIPTION

The `nng_listener_create()` function creates a newly initialized `nng_listener` object, associated with socket *s*, and configured to listen at the address specified by *url*, and stores a pointer to at the location referenced by *listenerp*.

Listeners are used to accept connections initiated by remote dialers. An incoming connection generally results in a pipe being created and attached to the socket *s*. Unlike dialers, listeners generally can create many pipes, which may be open concurrently.

**Tip**\

While it is convenient to think of listeners as servers, the relationship between the listener or dialer is orthogonal to any server or client status that might be associated with a given protocol. For example, a *req* socket might have associated dialers, but might also have associated listeners. It may even have some of each at the same time!

The listener is not started, but may be further configured with the `nng_listener_setopt()` family of functions.

Once it is fully configured, the listener may be started using the `nng_listener_start()` function.

**Tip**\

If no specific configuration is required, consider using the simpler `nng_listen()` function instead.

## RETURN VALUES

This function returns 0 on success, and non-zero otherwise.

## ERRORS

`NNG_EADDRINVAL`

An invalid *url* was specified.

`NNG_ECLOSED`

The socket *s* is not open.

`NNG_ENOMEM`

Insufficient memory is available.

## SEE ALSO

[nng\_dialer\_create(3)](/nng_dialer_create/3.md) [nng\_listen(3)](/nng_listen/3.md), [nng\_listener\_close(3)](/nng_listener_close/3.md), [nng\_listener\_getopt(3)](/nng_listener_getopt/3.md), [nng\_listener\_setopt(3)](/nng_listener_setopt/3.md), [nng\_listener\_start(3)](/nng_listener_start/3.md), [nng\_strerror(3)](/nng_strerror/3.md), [nng\_listener(5)](/nng_listener/5.md), [nng(7)](/nng/7.md)
