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

NAME

6       nn_bind - add a local endpoint to the socket
7

SYNOPSIS

9       #include <nanomsg/nn.h>
10
11       int nn_bind (int s, const char *addr);
12

DESCRIPTION

14       Adds a local endpoint to the socket s. The endpoint can be then used by
15       other applications to connect to.
16
17       The addr argument consists of two parts as follows:
18       transport://address. The transport specifies the underlying transport
19       protocol to use. The meaning of the address part is specific to the
20       underlying transport protocol.
21
22       For the list of available transport protocols check the list on
23       nanomsg(7) manual page.
24
25       Maximum length of the addr parameter is specified by NN_SOCKADDR_MAX
26       defined in <nanomsg/nn.h> header file.
27
28       Note that nn_bind and nn_connect(3) may be called multiple times on the
29       same socket thus allowing the socket to communicate with multiple
30       heterogeneous endpoints.
31

NOTE

33       Unlike with traditional BSD sockets, this function operates
34       asynchronously, and returns to the caller before the operation is
35       complete. As a result, attempts to send data or receive data on the
36       socket may not succeed until the underlying transport actually
37       establishes a connection.
38

RETURN VALUE

40       If the function succeeds positive endpoint ID is returned. Endpoint ID
41       can be later used to remove the endpoint from the socket via
42       nn_shutdown(3) function.
43
44       If the function fails, then -1 is returned and errno is set to to one
45       of the values defined below.
46

ERRORS

48       EBADF
49           The provided socket is invalid.
50
51       EMFILE
52           Maximum number of active endpoints was reached.
53
54       EINVAL
55           The syntax of the supplied address is invalid.
56
57       ENAMETOOLONG
58           The supplied address is too long.
59
60       EPROTONOSUPPORT
61           The requested transport protocol is not supported.
62
63       EADDRNOTAVAIL
64           The requested endpoint is not local.
65
66       ENODEV
67           Address specifies a nonexistent interface.
68
69       EADDRINUSE
70           The requested local endpoint is already in use.
71
72       ETERM
73           The library is terminating.
74

EXAMPLE

76           s = nn_socket (AF_SP, NN_PUB);
77           eid1 = nn_bind (s, "inproc://test");
78           eid2 = nn_bind (s, "tcp://127.0.0.1:5560");
79

SEE ALSO

81       nn_inproc(7) nn_ipc(7) nn_tcp(7) nn_socket(3) nn_connect(3)
82       nn_shutdown(3) nanomsg(7)
83

AUTHORS

85       Martin Sustrik <sustrik@250bpm.com> Garrett D’Amore
86       <garrett@damore.org>
87
88
89
90                                  2023-07-20                        NN_BIND(3)
Impressum