summaryrefslogtreecommitdiff
path: root/docs/ref/ctx/nng_ctx_id.adoc
blob: ebd052132eceb6600246cc5b8e5d4583c560881e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## nng_ctx_id

Return numeric context identifier.

### Synopsis

```c
#include <nng/nng.h>

int nng_ctx_id(nng_ctx c);
```

### Description

The `nng_ctx_id` function returns a positive identifier for the context _c_,  if it is valid.
Otherwise it returns `-1`.

A context is considered valid if it was ever opened with xref:nng_ctx_open.adoc[`nng_ctx_open`].

Contexts that are allocated on the stack or statically should be initialized with the macro ((`NNG_CTX_INITIALIZER`)) to ensure that they cannot be confused with another valid context.

### Return Values

This function returns the positive value for the context identifier, or `-1` if the context is invalid.


### See Also

xref:nng_ctx_open.adoc[nng_ctx_open]