'\" t .\" Title: nn_device .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 .\" Date: 2024-02-21 .\" Manual: nanomsg 1.2.1 .\" Source: \ \& .\" Language: English .\" .TH "NN_DEVICE" "3" "2024-02-21" "\ \&" "nanomsg 1.2.1" .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" nn_device \- start a device .SH "SYNOPSIS" .sp \fB#include \fP .sp \fBint nn_device (int \fIs1\fP, int \fIs2\fP);\fP .SH "DESCRIPTION" .sp Starts a device to forward messages between two sockets. If both sockets are valid, \fInn_device\fP function loops and sends any messages received from \fIs1\fP to \fIs2\fP and vice versa. If only one socket is valid and the other is negative, \fInn_device\fP works in a "loopback" mode \(em it loops and sends any messages received from the socket back to itself. .sp To break the loop and make \fInn_device\fP function exit use the nn_term(3) function. .SH "RETURN VALUE" .sp The function loops until it hits an error. In such a case it returns \-1 and sets \fIerrno\fP to one of the values defined below. .SH "ERRORS" .sp \fBEBADF\fP .RS 4 One of the provided sockets is invalid. .RE .sp \fBEINVAL\fP .RS 4 Either one of the socket is not an AF_SP_RAW socket; or the two sockets don\(cqt belong to the same protocol; or the directionality of the sockets doesn\(cqt fit (e.g. attempt to join two SINK sockets to form a device). .RE .sp \fBEINTR\fP .RS 4 The operation was interrupted by delivery of a signal. .RE .sp \fBETERM\fP .RS 4 The library is terminating. .RE .SH "EXAMPLE" .sp .if n .RS 4 .nf .fam C 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); .fam .fi .if n .RE .SH "SEE ALSO" .sp nn_socket(3) nn_term(3) nanomsg(7) .SH "AUTHORS" .sp .MTO "sustrik\(at250bpm.com" "Martin Sustrik" ""