1ZMQ_CONNECT(3)                    0MQ Manual                    ZMQ_CONNECT(3)
2
3
4

NAME

6       zmq_connect - create outgoing connection from socket
7

SYNOPSIS

9       int zmq_connect (void *socket, const char *endpoint);
10

DESCRIPTION

12       The zmq_connect() function connects the socket to an endpoint and then
13       accepts incoming connections on that endpoint.
14
15       The endpoint is a string consisting of a transport:// followed by an
16       address. The transport specifies the underlying protocol to use. The
17       address specifies the transport-specific address to connect to.
18
19       0MQ provides the the following transports:
20
21       tcp
22           unicast transport using TCP, see zmq_tcp(7)
23
24       ipc
25           local inter-process communication transport, see zmq_ipc(7)
26
27       inproc
28           local in-process (inter-thread) communication transport, see
29           zmq_inproc(7)
30
31       pgm, epgm
32           reliable multicast transport using PGM, see zmq_pgm(7)
33
34       vmci
35           virtual machine communications interface (VMCI), see zmq_vmci(7)
36
37       udp
38           unreliable unicast and multicast using UDP, see zmq_udp(7)
39
40       Every 0MQ socket type except ZMQ_PAIR and ZMQ_CHANNEL supports
41       one-to-many and many-to-one semantics. The precise semantics depend on
42       the socket type and are defined in zmq_socket(3).
43
44           Note
45           for most transports and socket types the connection is not
46           performed immediately but as needed by 0MQ. Thus a successful call
47           to zmq_connect() does not mean that the connection was or could
48           actually be established. Because of this, for most transports and
49           socket types the order in which a server socket is bound and a
50           client socket is connected to it does not matter. The ZMQ_PAIR and
51           ZMQ_CHANNEL sockets are an exception, as they do not automatically
52           reconnect to endpoints.
53
54           Note
55           following a zmq_connect(), for socket types except for ZMQ_ROUTER,
56           the socket enters its normal ready state. By contrast, following a
57           zmq_bind() alone, the socket enters a mute state in which the
58           socket blocks or drops messages according to the socket type, as
59           defined in zmq_socket(3). A ZMQ_ROUTER socket enters its normal
60           ready state for a specific peer only when handshaking is complete
61           for that peer, which may take an arbitrary time.
62
63           Note
64           for some socket types, multiple connections to the same endpoint
65           don’t really make sense (see
66           https://github.com/zeromq/libzmq/issues/788). For those socket
67           types, any attempt to connect to an already connected endpoint is
68           silently ignored (i.e., returns zero). This behavior applies to
69           ZMQ_DEALER, ZMQ_SUB, ZMQ_PUB, and ZMQ_REQ socket types.
70

RETURN VALUE

72       The zmq_connect() function returns zero if successful. Otherwise it
73       returns -1 and sets errno to one of the values defined below.
74

ERRORS

76       EINVAL
77           The endpoint supplied is invalid.
78
79       EPROTONOSUPPORT
80           The requested transport protocol is not supported.
81
82       ENOCOMPATPROTO
83           The requested transport protocol is not compatible with the socket
84           type.
85
86       ETERM
87           The 0MQ context associated with the specified socket was
88           terminated.
89
90       ENOTSOCK
91           The provided socket was invalid.
92
93       EMTHREAD
94           No I/O thread is available to accomplish the task.
95

EXAMPLE

97       Connecting a subscriber socket to an in-process and a TCP transport.
98
99           /* Create a ZMQ_SUB socket */
100           void *socket = zmq_socket (context, ZMQ_SUB);
101           assert (socket);
102           /* Connect it to an in-process transport with the address 'my_publisher' */
103           int rc = zmq_connect (socket, "inproc://my_publisher");
104           assert (rc == 0);
105           /* Connect it to the host server001, port 5555 using a TCP transport */
106           rc = zmq_connect (socket, "tcp://server001:5555");
107           assert (rc == 0);
108
109

SEE ALSO

111       zmq_bind(3) zmq_socket(3) zmq(7)
112

AUTHORS

114       This page was written by the 0MQ community. To make a change please
115       read the 0MQ Contribution Policy at
116       http://www.zeromq.org/docs:contributing.
117
118
119
1200MQ 4.3.4                         01/30/2021                    ZMQ_CONNECT(3)
Impressum