'\" t
.\"     Title: nn_device
.\"    Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 2.0.26
.\"      Date: 2021-02-08
.\"    Manual: NNG Reference Manual
.\"    Source: \ \&
.\"  Language: English
.\"
.TH "NN_DEVICE" "3compat" "2021-02-08" "\ \&" "NNG Reference Manual"
.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 \- create forwarding device (compatible API)
.SH "SYNOPSIS"
.sp
.if n .RS 4
.nf
.fam C
#include <nanomsg/nn.h>

int nn_device(int sock1, int sock2);
.fam
.fi
.if n .RE
.SH "DESCRIPTION"
.sp
The \f(CRnn_device()\fP function is used to create a forwarder, where messages
received on one of the two sockets \fIsock1\fP and \fIsock2\fP are forwarded to
the other.
.if n .sp
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
.B Note
.ps -1
.br
.sp
This function is provided for API
compatibility with legacy \fIlibnanomsg\fP.
Consider using the relevant modern API instead.
.sp .5v
.RE
.sp
The two sockets must be compatible, and must be
raw mode
sockets.
More detail about devices and how they can be used is available in the
new style nng_device() documentation.
.SH "RETURN VALUES"
.sp
This function blocks forever, and will return \-1 only when
one of the sockets is closed or an error occurs.
.SH "ERRORS"
.sp
\f(CREBADF\fP
.RS 4
One of the two sockets is invalid or not open, or has
.RE
.sp
\f(CREINVAL\fP
.RS 4
The sockets are not compatible with each other, or not both raw.
.RE
.sp
\f(CRENOMEM\fP
.RS 4
Insufficient memory is available.
.RE
.SH "SEE ALSO"
.sp
nn_errno(3compat),
nn_socket(3compat),
nng_compat(3compat),
nng(7)