1NN_SOCKET(3)                     nanomsg 1.1.5                    NN_SOCKET(3)
2
3
4

NAME

6       nn_socket - create an SP socket
7

SYNOPSIS

9       #include <nanomsg/nn.h>
10
11       int nn_socket (int domain, int protocol);
12

DESCRIPTION

14       Creates an SP socket with specified domain and protocol. Returns a file
15       descriptor for the newly created socket.
16
17       Following domains are defined at the moment:
18
19       AF_SP
20           Standard full-blown SP socket.
21
22       AF_SP_RAW
23           Raw SP socket. Raw sockets omit the end-to-end functionality found
24           in AF_SP sockets and thus can be used to implement intermediary
25           devices in SP topologies.
26
27       protocol parameter defines the type of the socket, which in turn
28       determines the exact semantics of the socket. Check manual pages for
29       individual SP protocols to get the list of available socket types.
30
31       The newly created socket is initially not associated with any
32       endpoints. In order to establish a message flow at least one endpoint
33       has to be added to the socket using nn_bind(3) or nn_connect(3)
34       function.
35
36       Also note that type argument as found in standard socket(2) function is
37       omitted from nn_socket. All the SP sockets are message-based and thus
38       of SOCK_SEQPACKET type.
39

RETURN VALUE

41       If the function succeeds file descriptor of the new socket is returned.
42       Otherwise, -1 is returned and errno is set to to one of the values
43       defined below.
44
45       Note that file descriptors returned by nn_socket function are not
46       standard file descriptors and will exhibit undefined behaviour when
47       used with system functions. Moreover, it may happen that a system file
48       descriptor and file descriptor of an SP socket will incidentally
49       collide (be equal).
50

ERRORS

52       EAFNOSUPPORT
53           Specified address family is not supported.
54
55       EINVAL
56           Unknown protocol.
57
58       EMFILE
59           The limit on the total number of open SP sockets or OS limit for
60           file descriptors has been reached.
61
62       ETERM
63           The library is terminating.
64

EXAMPLE

66           int s = nn_socket (AF_SP, NN_PUB);
67           assert (s >= 0);
68

SEE ALSO

70       nn_pubsub(7) nn_reqrep(7) nn_pipeline(7) nn_survey(7) nn_bus(7)
71       nn_bind(3) nn_connect(3) nn_close(3) nanomsg(7)
72

AUTHORS

74       Martin Sustrik <sustrik@250bpm.com>
75
76
77
78                                  2020-08-24                      NN_SOCKET(3)
Impressum