#include <nng/nng.h>
int nng_listener_create(nng_listener *listenerp, nng_socket s, const char *url);
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.
|
NNG_EADDRINVAL
|
An invalid url was specified. |
NNG_ECLOSED
|
The socket s is not open. |
NNG_ENOMEM
|
Insufficient memory is available. |