1NN_DEVICE(3)                     nanomsg 1.1.5                    NN_DEVICE(3)
2
3
4

NAME

6       nn_device - start a device
7

SYNOPSIS

9       #include <nanomsg/nn.h>
10
11       int nn_device (int s1, int s2);
12

DESCRIPTION

14       Starts a device to forward messages between two sockets. If both
15       sockets are valid, nn_device function loops and sends any messages
16       received from s1 to s2 and vice versa. If only one socket is valid and
17       the other is negative, nn_device works in a "loopback" mode — it loops
18       and sends any messages received from the socket back to itself.
19
20       To break the loop and make nn_device function exit use the nn_term(3)
21       function.
22

RETURN VALUE

24       The function loops until it hits an error. In such a case it returns -1
25       and sets errno to one of the values defined below.
26

ERRORS

28       EBADF
29           One of the provided sockets is invalid.
30
31       EINVAL
32           Either one of the socket is not an AF_SP_RAW socket; or the two
33           sockets don’t belong to the same protocol; or the directionality of
34           the sockets doesn’t fit (e.g. attempt to join two SINK sockets to
35           form a device).
36
37       EINTR
38           The operation was interrupted by delivery of a signal.
39
40       ETERM
41           The library is terminating.
42

EXAMPLE

44           int s1 = nn_socket (AF_SP_RAW, NN_REQ);
45           nn_bind (s1, "tcp://127.0.0.1:5555");
46           int s2 = nn_socket (AF_SP_RAW, NN_REP);
47           nn_bind (s2, "tcp://127.0.0.1:5556");
48           nn_device (s1, s2);
49

SEE ALSO

51       nn_socket(3) nn_term(3) nanomsg(7)
52

AUTHORS

54       Martin Sustrik <sustrik@250bpm.com>
55
56
57
58                                  2021-01-26                      NN_DEVICE(3)
Impressum