'\" t
.\"     Title: nng_listener_getopt
.\"    Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 2.0.20
.\"      Date: 2024-05-31
.\"    Manual: NNG Reference Manual
.\"    Source: \ \&
.\"  Language: English
.\"
.TH "NNG_LISTENER_GETOPT" "3" "2024-05-31" "\ \&" "NNG Reference Manual"
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.ss \n[.ss] 0
.nh
.ad l
.de URL
\fI\\$2\fP <\\$1>\\$3
..
.als MTO URL
.if \n[.g] \{\
.  mso www.tmac
.  am URL
.    ad l
.  .
.  am MTO
.    ad l
.  .
.  LINKSTYLE blue R < >
.\}
.SH "NAME"
nng_listener_getopt \- get listener option
.SH "SYNOPSIS"
.sp
.if n .RS 4
.nf
.fam C
#include <nng/nng.h>

int nng_listener_getopt(nng_listener l, const char *opt, void *val, size_t *valszp);

int nng_listener_getopt_bool(nng_listener l, const char *opt, bool *bvalp);

int nng_listener_getopt_int(nng_listener l, const char *opt, int *ivalp);

int nng_listener_getopt_ms(nng_listener l, const char *opt, nng_duration *durp);

int nng_listener_getopt_ptr(nng_listener l, const char *opt, void **ptr);

int nng_listener_getopt_size(nng_listener l, const char *opt, size_t *zp);

int nng_listener_getopt_sockaddr(nng_listener l, const char *opt, nng_sockaddr *sap);

int nng_listener_getopt_string(nng_listener l, const char *opt, char **strp);

int nng_listener_getopt_uint64(nng_listener l, const char *opt, uint64_t *u64p);
.fam
.fi
.if n .RE
.SH "DESCRIPTION"
.if n .sp
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
.B Important
.ps -1
.br
.sp
These functions are deprecated.  Please see nng_listener_get.
They may not be present if the library was built with \f(CRNNG_ELIDE_DEPRECATED\fP.
.sp .5v
.RE
.sp

The \f(CRnng_listener_getopt()\fP functions are used to retrieve option values for
the listener \fIl\fP.
The actual options that may be retrieved in this way
vary, and many are documented in nng_options(5).
.sp
Additionally some transport\-specific options
are documented with the transports themselves.
.SS "Forms"
.sp
In all of these forms, the option \fIopt\fP is retrieved from the listener \fIl\fP.
The forms vary based on the type of the option they take.
.sp
The details of the type, size, and semantics of the option will depend
on the actual option, and will be documented with the option itself.
.sp
\f(CRnng_listener_getopt()\fP
.RS 4
This function is untyped and can be used to retrieve the value of any option.
The caller must store a pointer to a buffer to receive the value in \fIval\fP,
and the size of the buffer shall be stored at the location referenced
by \fIvalszp\fP.
.br

.br
When the function returns, the actual size of the data copied (or that
would have been copied if sufficient space were present) is stored at
the location referenced by \fIvalszp\fP.
If the caller\(cqs buffer is not large
enough to hold the entire object, then the copy is truncated.  Therefore
the caller should validate that the returned size in \fIvalszp\fP does not
exceed the original buffer size to check for truncation.
.br

.br
It is acceptable to pass \f(CRNULL\fP for \fIval\fP if the value in \fIvalszp\fP is zero.
This can be used to determine the size of the buffer needed to receive
the object.
.RE
.if n .sp
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
.B Tip
.ps -1
.br
.sp
It may be easier to use one of the typed forms of this function.
.sp .5v
.RE
.sp
\f(CRnng_listener_getopt_bool()\fP
.RS 4
This function is for options which take a Boolean (\f(CRbool\fP).
The value will be stored at \fIbvalp\fP.
.RE
.sp
\f(CRnng_listener_getopt_int()\fP
.RS 4
This function is for options which take an integer (\f(CRint\fP).
The value will be stored at \fIivalp\fP.
.RE
.sp
\f(CRnng_listener_getopt_ms()\fP
.RS 4
This function is used to retrieve time durations
(such as timeouts), stored in \fIdurp\fP as a number of milliseconds.
.RE
.sp
\f(CRnng_listener_getopt_ptr()\fP
.RS 4
This function is used to retrieve a pointer, \fIptr\fP, to structured data.
The data referenced by \fIptr\fP is generally managed using other functions.
Note that this form is somewhat special in that the object is generally
not copied, but instead the \fBpointer\fP to the object is copied.
.RE
.sp
\f(CRnng_listener_getopt_size()\fP
.RS 4
This function is used to retrieve a size into the pointer \fIzp\fP,
typically for buffer sizes, message maximum sizes, and similar options.
.RE
.sp
\f(CRnng_listener_getopt_sockaddr()\fP
.RS 4
This function is used to retrieve an \f(CRnng_sockaddr\fP
into the value referenced by \fIsap\fP.
.RE
.sp
\f(CRnng_listener_getopt_string()\fP
.RS 4
This function is used to retrieve a string into \fIstrp\fP.
This string is created from the source using \f(CRnng_strdup()\fP
and consequently must be freed by the caller using
\f(CRnng_strfree()\fP when it is no longer needed.
.RE
.sp
\f(CRnng_listener_getopt_uint64()\fP
.RS 4
This function is used to retrieve a 64\-bit unsigned value into the value
referenced by \fIu64p\fP.
This is typically used for options related to identifiers, network
numbers, and similar.
.RE
.SH "RETURN VALUES"
.sp
These functions return 0 on success, and non\-zero otherwise.
.SH "ERRORS"
.sp
\f(CRNNG_EBADTYPE\fP
.RS 4
Incorrect type for option.
.RE
.sp
\f(CRNNG_ECLOSED\fP
.RS 4
Parameter \fIl\fP does not refer to an open listener.
.RE
.sp
\f(CRNNG_EINVAL\fP
.RS 4
Size of destination \fIval\fP too small for object.
.RE
.sp
\f(CRNNG_ENOMEM\fP
.RS 4
Insufficient memory exists.
.RE
.sp
\f(CRNNG_ENOTSUP\fP
.RS 4
The option \fIopt\fP is not supported.
.RE
.sp
\f(CRNNG_EWRITEONLY\fP
.RS 4
The option \fIopt\fP is write\-only.
.RE
.SH "SEE ALSO"
.sp
nng_listen(3),
nng_listener_create(3)
nng_listener_setopt(3)
nng_getopt(3),
nng_strdup(3),
nng_strerror(3),
nng_strfree(3),
nng_duration(5),
nng_listener(5),
nng_options(5),
nng_sockaddr(5),
nng(7)