# nng_stream_listener_listen(3str) Manual Page

## NAME

nng_stream_listener_listen - bind listener to configured address

## SYNOPSIS

    #include <nng/nng.h>

    int nng_stream_listener_listen(nng_stream_listener *l);

## DESCRIPTION

The `nng_stream_listener_listen()` attempts to bind the listener l to the local address specified when the listener was created.

This must generally be done before accepting incoming connections using `nng_stream_listener_accept()`.

For some transports this will also perform other actiosn. For example, with TCP listeners it will configure the underlying port into passive mode, ready to accept an incoming connection, and established a listen queue for receiving incoming connections.

If binding the listener requires allocation of an address (for example when a TCP port number of zero is specified, indicating that an ephemeral port should be used), this operation will allocate that resource. This can permit retrieval of the selected address using `nng_stream_listener_get()`, typically with the `NNG_OPT_LOCADDR` option.

## RETURN VALUES

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

## ERRORS

`NNG_EADDRINUSE` | The address is already in use.
`NNG_EADDRINVAL` | The address is invalid or unavailable.
`NNG_ECLOSED` | The listener has been closed.
`NNG_ESTATE` | The listener is already bound.

## SEE ALSO

nng_stream_listener_accept(3str), nng_strerror(3), nng_stream_listener(5)