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

int nn_socket(int af, int proto);
.fam
.fi
.if n .RE
.SH "DESCRIPTION"
.sp
The \f(CRnn_socket()\fP function creates socket using the address family \fIaf\fP and
protocol \fIproto\fP and returns it.
.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
.if n .sp
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
.B Important
.ps -1
.br
.sp
Mixing the compatibility API and the modern API is not supported
on a given socket.
.sp .5v
.RE
.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
Some protocols, transports, and features are only available in the modern API.
.sp .5v
.RE
.sp
The address family \fIaf\fP can be one of two values:
.sp
\f(CRAF_SP\fP
.RS 4
Normal socket.
.RE
.sp
\f(CRAF_SP_RAW\fP
.RS 4
Raw mode socket.
.RE
.sp
The protocol indicates the protocol to be used when creating the socket.
The following protocols are defined:
.sp
\f(CRNN_PAIR\fP
.RS 4
Pair protocol.
.RE
.sp
\f(CRNN_PUB\fP
.RS 4
Publisher protocol.
.RE
.sp
\f(CRNN_SUB\fP
.RS 4
Subscriber protocol.
.RE
.sp
\f(CRNN_REQ\fP
.RS 4
Requestor protocol.
.RE
.sp
\f(CRNN_REP\fP
.RS 4
Replier protocol.
.RE
.sp
\f(CRNN_PUSH\fP
.RS 4
Push protocol.
.RE
.sp
\f(CRNN_PULL\fP
.RS 4
Pull protocol.
.RE
.sp
\f(CRNN_SURVEYOR\fP
.RS 4
Surveyor protocol.
.RE
.sp
\f(CRNN_RESPONDENT\fP
.RS 4
Respondent protocol.
.RE
.sp
\f(CRNN_BUS\fP
.RS 4
Bus protocol.
.RE
.SH "RETURN VALUES"
.sp
This function returns a valid socket number on success, and \-1 on failure.
.SH "ERRORS"
.sp
\f(CRENOMEM\fP
.RS 4
Insufficient memory is available.
.RE
.sp
\f(CRENOTSUP\fP
.RS 4
The protocol is not supported.
.RE
.sp
\f(CRETERM\fP
.RS 4
The library is shutting down.
.RE
.SH "SEE ALSO"
.sp
nng_socket(5),
nn_close(3compat),
nn_errno(3compat),
nng_compat(3compat),
nng(7)