SYNOPSIS
#include <nng/nng.h>
#include <nng/supplemental/tcp/tcp.h>
int nng_tcp_listener_listen(nng_tcp_listener l, const nng_sockaddr *sa);
DESCRIPTION
The nng_tcp_listener_listen() attempts to bind the listener l
to the local address specified by sa, which must be in the
NNG_AF_INET or NNG_AF_INET6 address family.
This also sets the underlying port into passive mode, ready to accept an incoming connection, and established a listen queue for receiving incoming connections. (The queue depth is system specific, but typically 128.)
The actual IPv4 or IPv6 address in sa may refer either to a locally configured interface address, or to a zero-valued adddress to indicate that all interfaces on the system should be bound.
The TCP port number may also be zero. In this case the system will choose a free TCP port at random, and use it.
The chosen port number may be retrieved using the
NNG_OPT_LOCADDR option with the
nng_tcp_listener_getopt() function.
RETURN VALUES
This function returns 0 on success, and non-zero otherwise.
ERRORS
NNG_EADDRINUSE
|
The address specified by sa is already in use. |
NNG_EADDRINVAL
|
The address specified by sa is invalid or unavailable. |
NNG_ECLOSED
|
The listener l has been closed. |
NNG_ESTATE
|
The listener l is already bound. |