table of contents
- experimental 1.2.1+dfsg-1
NN_DEVICE(3) | nanomsg 1.2.1 | NN_DEVICE(3) |
NAME¶
nn_device - start a device
SYNOPSIS¶
#include <nanomsg/nn.h>
int nn_device (int s1, int s2);
DESCRIPTION¶
Starts a device to forward messages between two sockets. If both sockets are valid, nn_device function loops and sends any messages received from s1 to s2 and vice versa. If only one socket is valid and the other is negative, nn_device works in a "loopback" mode — it loops and sends any messages received from the socket back to itself.
To break the loop and make nn_device function exit use the nn_term(3) function.
RETURN VALUE¶
The function loops until it hits an error. In such a case it returns -1 and sets errno to one of the values defined below.
ERRORS¶
EBADF
EINVAL
EINTR
ETERM
EXAMPLE¶
int s1 = nn_socket (AF_SP_RAW, NN_REQ); nn_bind (s1, "tcp://127.0.0.1:5555"); int s2 = nn_socket (AF_SP_RAW, NN_REP); nn_bind (s2, "tcp://127.0.0.1:5556"); nn_device (s1, s2);
SEE ALSO¶
AUTHORS¶
Martin Sustrik <sustrik@250bpm.com>
2024-02-21 |