summaryrefslogtreecommitdiff
path: root/docs/ref/msg/nng_msg_get_pipe.adoc
blob: fa816d2b917fe174bb28960faecf8c09ff618f17 (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
30
31
32
33
## nng_msg_get_pipe

Get pipe for message.

### Synopsis

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

nng_pipe nng_msg_get_pipe(nng_msg *msg);
```

### Description

The `nng_msg_get_pipe` function returns the xref:../pipe/index.adoc[pipe] object associated with message _msg_.
On receive, this is the pipe from which a message was received.
On transmit, this would be the pipe that the message should be delivered to, if a specific peer is required.

Not all protocols support overriding the destination pipe.

The most usual use case for this is to obtain information about the peer from which the message was received.
This can be used to provide different behaviors for different peers such as a higher level of authentication for peers located on an untrusted network.
The xref:../pipe/nng_pipe_get.adoc[`nng_pipe_get`] function is useful in this situation.

### Return Values

This function returns the pipe associated with this message.
If the message is not associated with a pipe, then xref:nng_pipe_id.adoc[`nng_pipe_id`] on the return value will return a negative number.

### See Also

xref:nng_msg_set_pipe.adoc[nng_msg_set_pipe],
xref:../pipe/nng_pipe_get.adoc[nng_pipe_get]