summaryrefslogtreecommitdiff
path: root/docs/ref/compat/nn_socket.adoc
blob: d5e88652336088c6fa0e1bdd2fb7594374789731 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
## nn_socket

Create socket (compatible API).

### Synopsis

```c
#include <nanomsg/nn.h>

int nn_socket(int af, int proto);
```

### Description

The `nn_socket` function creates socket using the address family _af_ and
protocol _proto_ and returns it.

The address family _af_ can be one of two values:

[horizontal]
`AF_SP`:: Normal socket.
`AF_SP_RAW`:: Raw mode socket.

The protocol indicates the protocol to be used when creating the socket.
The following protocols are defined:

[horizontal]
`NN_PAIR`:: xref:nng_pair.adoc[Pair] protocol.
`NN_PUB`:: xref:nng_pub.adoc[Publisher] protocol.
`NN_SUB`:: xref:nng_sub.adoc[Subscriber] protocol.
`NN_REQ`:: xref:nng_req.adoc[Requestor] protocol.
`NN_REP`:: xref:nng_rep.adoc[Replier] protocol.
`NN_PUSH`:: xref:nng_push.adoc[Push] protocol.
`NN_PULL`:: xref:nng_pull.adoc[Pull] protocol.
`NN_SURVEYOR`:: xref:nng_surveyor.adoc[Surveyor] protocol.
`NN_RESPONDENT`:: xref:nng_respondent.adoc[Respondent] protocol.
`NN_BUS`:: xref:nng_bus.adoc[Bus] protocol.

### Return Values

This function returns a valid socket number on success, and -1 on failure.

### Errors

[horizontal]
`ENOMEM`:: Insufficient memory is available.
`ENOTSUP`:: The protocol is not supported.
`ETERM`:: The library is shutting down.

### See Also

xref:nng_socket.adoc[nng_socket],
xref:nn_close.adoc[nn_close],
xref:nn_errno.adoc[nn_errno]