1ZSOCK(3)                          CZMQ Manual                         ZSOCK(3)
2
3
4

NAME

6       zsock - Class for high-level socket API that hides libzmq contexts and
7       sockets
8

SYNOPSIS

10       //  This is a stable class, and may not change except for emergencies. It
11       //  is provided in stable builds.
12       //  This class has draft methods, which may change over time. They are not
13       //  in stable releases, by default. Use --enable-drafts to enable.
14       //  Create a new socket. Returns the new socket, or NULL if the new socket
15       //  could not be created. Note that the symbol zsock_new (and other
16       //  constructors/destructors for zsock) are redirected to the *_checked
17       //  variant, enabling intelligent socket leak detection. This can have
18       //  performance implications if you use a LOT of sockets. To turn off this
19       //  redirection behaviour, define ZSOCK_NOCHECK.
20       CZMQ_EXPORT zsock_t *
21           zsock_new (int type);
22
23       //  Create a PUB socket. Default action is bind.
24       CZMQ_EXPORT zsock_t *
25           zsock_new_pub (const char *endpoint);
26
27       //  Create a SUB socket, and optionally subscribe to some prefix string. Default
28       //  action is connect.
29       CZMQ_EXPORT zsock_t *
30           zsock_new_sub (const char *endpoint, const char *subscribe);
31
32       //  Create a REQ socket. Default action is connect.
33       CZMQ_EXPORT zsock_t *
34           zsock_new_req (const char *endpoint);
35
36       //  Create a REP socket. Default action is bind.
37       CZMQ_EXPORT zsock_t *
38           zsock_new_rep (const char *endpoint);
39
40       //  Create a DEALER socket. Default action is connect.
41       CZMQ_EXPORT zsock_t *
42           zsock_new_dealer (const char *endpoint);
43
44       //  Create a ROUTER socket. Default action is bind.
45       CZMQ_EXPORT zsock_t *
46           zsock_new_router (const char *endpoint);
47
48       //  Create a PUSH socket. Default action is connect.
49       CZMQ_EXPORT zsock_t *
50           zsock_new_push (const char *endpoint);
51
52       //  Create a PULL socket. Default action is bind.
53       CZMQ_EXPORT zsock_t *
54           zsock_new_pull (const char *endpoint);
55
56       //  Create an XPUB socket. Default action is bind.
57       CZMQ_EXPORT zsock_t *
58           zsock_new_xpub (const char *endpoint);
59
60       //  Create an XSUB socket. Default action is connect.
61       CZMQ_EXPORT zsock_t *
62           zsock_new_xsub (const char *endpoint);
63
64       //  Create a PAIR socket. Default action is connect.
65       CZMQ_EXPORT zsock_t *
66           zsock_new_pair (const char *endpoint);
67
68       //  Create a STREAM socket. Default action is connect.
69       CZMQ_EXPORT zsock_t *
70           zsock_new_stream (const char *endpoint);
71
72       //  Destroy the socket. You must use this for any socket created via the
73       //  zsock_new method.
74       CZMQ_EXPORT void
75           zsock_destroy (zsock_t **self_p);
76
77       //  Bind a socket to a formatted endpoint. For tcp:// endpoints, supports
78       //  ephemeral ports, if you specify the port number as "*". By default
79       //  zsock uses the IANA designated range from C000 (49152) to FFFF (65535).
80       //  To override this range, follow the "*" with "[first-last]". Either or
81       //  both first and last may be empty. To bind to a random port within the
82       //  range, use "!" in place of "*".
83       //
84       //  Examples:
85       //      tcp://127.0.0.1:*           bind to first free port from C000 up
86       //      tcp://127.0.0.1:!           bind to random port from C000 to FFFF
87       //      tcp://127.0.0.1:*[60000-]   bind to first free port from 60000 up
88       //      tcp://127.0.0.1:![-60000]   bind to random port from C000 to 60000
89       //      tcp://127.0.0.1:![55000-55999]
90       //                                  bind to random port from 55000 to 55999
91       //
92       //  On success, returns the actual port number used, for tcp:// endpoints,
93       //  and 0 for other transports. On failure, returns -1. Note that when using
94       //  ephemeral ports, a port may be reused by different services without
95       //  clients being aware. Protocols that run on ephemeral ports should take
96       //  this into account.
97       CZMQ_EXPORT int
98           zsock_bind (zsock_t *self, const char *format, ...) CHECK_PRINTF (2);
99
100       //  Returns last bound endpoint, if any.
101       CZMQ_EXPORT const char *
102           zsock_endpoint (zsock_t *self);
103
104       //  Unbind a socket from a formatted endpoint.
105       //  Returns 0 if OK, -1 if the endpoint was invalid or the function
106       //  isn't supported.
107       CZMQ_EXPORT int
108           zsock_unbind (zsock_t *self, const char *format, ...) CHECK_PRINTF (2);
109
110       //  Connect a socket to a formatted endpoint
111       //  Returns 0 if OK, -1 if the endpoint was invalid.
112       CZMQ_EXPORT int
113           zsock_connect (zsock_t *self, const char *format, ...) CHECK_PRINTF (2);
114
115       //  Disconnect a socket from a formatted endpoint
116       //  Returns 0 if OK, -1 if the endpoint was invalid or the function
117       //  isn't supported.
118       CZMQ_EXPORT int
119           zsock_disconnect (zsock_t *self, const char *format, ...) CHECK_PRINTF (2);
120
121       //  Attach a socket to zero or more endpoints. If endpoints is not null,
122       //  parses as list of ZeroMQ endpoints, separated by commas, and prefixed by
123       //  '@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all
124       //  endpoints were valid, or -1 if there was a syntax error. If the endpoint
125       //  does not start with '@' or '>', the serverish argument defines whether
126       //  it is used to bind (serverish = true) or connect (serverish = false).
127       CZMQ_EXPORT int
128           zsock_attach (zsock_t *self, const char *endpoints, bool serverish);
129
130       //  Returns socket type as printable constant string.
131       CZMQ_EXPORT const char *
132           zsock_type_str (zsock_t *self);
133
134       //  Send a 'picture' message to the socket (or actor). The picture is a
135       //  string that defines the type of each frame. This makes it easy to send
136       //  a complex multiframe message in one call. The picture can contain any
137       //  of these characters, each corresponding to one or two arguments:
138       //
139       //      i = int (signed)
140       //      1 = uint8_t
141       //      2 = uint16_t
142       //      4 = uint32_t
143       //      8 = uint64_t
144       //      s = char *
145       //      b = byte *, size_t (2 arguments)
146       //      c = zchunk_t *
147       //      f = zframe_t *
148       //      h = zhashx_t *
149       //      l = zlistx_t * (DRAFT)
150       //      U = zuuid_t *
151       //      p = void * (sends the pointer value, only meaningful over inproc)
152       //      m = zmsg_t * (sends all frames in the zmsg)
153       //      z = sends zero-sized frame (0 arguments)
154       //      u = uint (deprecated)
155       //
156       //  Note that s, b, c, and f are encoded the same way and the choice is
157       //  offered as a convenience to the sender, which may or may not already
158       //  have data in a zchunk or zframe. Does not change or take ownership of
159       //  any arguments. Returns 0 if successful, -1 if sending failed for any
160       //  reason.
161       CZMQ_EXPORT int
162           zsock_send (void *self, const char *picture, ...);
163
164       //  Send a 'picture' message to the socket (or actor). This is a va_list
165       //  version of zsock_send (), so please consult its documentation for the
166       //  details.
167       CZMQ_EXPORT int
168           zsock_vsend (void *self, const char *picture, va_list argptr);
169
170       //  Receive a 'picture' message to the socket (or actor). See zsock_send for
171       //  the format and meaning of the picture. Returns the picture elements into
172       //  a series of pointers as provided by the caller:
173       //
174       //      i = int * (stores signed integer)
175       //      4 = uint32_t * (stores 32-bit unsigned integer)
176       //      8 = uint64_t * (stores 64-bit unsigned integer)
177       //      s = char ** (allocates new string)
178       //      b = byte **, size_t * (2 arguments) (allocates memory)
179       //      c = zchunk_t ** (creates zchunk)
180       //      f = zframe_t ** (creates zframe)
181       //      U = zuuid_t * (creates a zuuid with the data)
182       //      h = zhashx_t ** (creates zhashx)
183       //      l = zlistx_t ** (creates zlistx) (DRAFT)
184       //      p = void ** (stores pointer)
185       //      m = zmsg_t ** (creates a zmsg with the remaining frames)
186       //      z = null, asserts empty frame (0 arguments)
187       //      u = uint * (stores unsigned integer, deprecated)
188       //
189       //  Note that zsock_recv creates the returned objects, and the caller must
190       //  destroy them when finished with them. The supplied pointers do not need
191       //  to be initialized. Returns 0 if successful, or -1 if it failed to recv
192       //  a message, in which case the pointers are not modified. When message
193       //  frames are truncated (a short message), sets return values to zero/null.
194       //  If an argument pointer is NULL, does not store any value (skips it).
195       //  An 'n' picture matches an empty frame; if the message does not match,
196       //  the method will return -1.
197       CZMQ_EXPORT int
198           zsock_recv (void *self, const char *picture, ...);
199
200       //  Receive a 'picture' message from the socket (or actor). This is a
201       //  va_list version of zsock_recv (), so please consult its documentation
202       //  for the details.
203       CZMQ_EXPORT int
204           zsock_vrecv (void *self, const char *picture, va_list argptr);
205
206       //  Send a binary encoded 'picture' message to the socket (or actor). This
207       //  method is similar to zsock_send, except the arguments are encoded in a
208       //  binary format that is compatible with zproto, and is designed to reduce
209       //  memory allocations. The pattern argument is a string that defines the
210       //  type of each argument. Supports these argument types:
211       //
212       //   pattern    C type                  zproto type:
213       //      1       uint8_t                 type = "number" size = "1"
214       //      2       uint16_t                type = "number" size = "2"
215       //      4       uint32_t                type = "number" size = "3"
216       //      8       uint64_t                type = "number" size = "4"
217       //      s       char *, 0-255 chars     type = "string"
218       //      S       char *, 0-2^32-1 chars  type = "longstr"
219       //      c       zchunk_t *              type = "chunk"
220       //      f       zframe_t *              type = "frame"
221       //      u       zuuid_t *               type = "uuid"
222       //      m       zmsg_t *                type = "msg"
223       //      p       void *, sends pointer value, only over inproc
224       //
225       //  Does not change or take ownership of any arguments. Returns 0 if
226       //  successful, -1 if sending failed for any reason.
227       CZMQ_EXPORT int
228           zsock_bsend (void *self, const char *picture, ...);
229
230       //  Receive a binary encoded 'picture' message from the socket (or actor).
231       //  This method is similar to zsock_recv, except the arguments are encoded
232       //  in a binary format that is compatible with zproto, and is designed to
233       //  reduce memory allocations. The pattern argument is a string that defines
234       //  the type of each argument. See zsock_bsend for the supported argument
235       //  types. All arguments must be pointers; this call sets them to point to
236       //  values held on a per-socket basis.
237       //  For types 1, 2, 4 and 8 the caller must allocate the memory itself before
238       //  calling zsock_brecv.
239       //  For types S, the caller must free the value once finished with it, as
240       //  zsock_brecv will allocate the buffer.
241       //  For type s, the caller must not free the value as it is stored in a
242       //  local cache for performance purposes.
243       //  For types c, f, u and m the caller must call the appropriate destructor
244       //  depending on the object as zsock_brecv will create new objects.
245       //  For type p the caller must coordinate with the sender, as it is just a
246       //  pointer value being passed.
247       CZMQ_EXPORT int
248           zsock_brecv (void *self, const char *picture, ...);
249
250       //  Set socket to use unbounded pipes (HWM=0); use this in cases when you are
251       //  totally certain the message volume can fit in memory. This method works
252       //  across all versions of ZeroMQ. Takes a polymorphic socket reference.
253       CZMQ_EXPORT void
254           zsock_set_unbounded (void *self);
255
256       //  Send a signal over a socket. A signal is a short message carrying a
257       //  success/failure code (by convention, 0 means OK). Signals are encoded
258       //  to be distinguishable from "normal" messages. Accepts a zsock_t or a
259       //  zactor_t argument, and returns 0 if successful, -1 if the signal could
260       //  not be sent. Takes a polymorphic socket reference.
261       CZMQ_EXPORT int
262           zsock_signal (void *self, byte status);
263
264       //  Wait on a signal. Use this to coordinate between threads, over pipe
265       //  pairs. Blocks until the signal is received. Returns -1 on error, 0 or
266       //  greater on success. Accepts a zsock_t or a zactor_t as argument.
267       //  Takes a polymorphic socket reference.
268       CZMQ_EXPORT int
269           zsock_wait (void *self);
270
271       //  If there is a partial message still waiting on the socket, remove and
272       //  discard it. This is useful when reading partial messages, to get specific
273       //  message types.
274       CZMQ_EXPORT void
275           zsock_flush (void *self);
276
277       //  Probe the supplied object, and report if it looks like a zsock_t.
278       //  Takes a polymorphic socket reference.
279       CZMQ_EXPORT bool
280           zsock_is (void *self);
281
282       //  Probe the supplied reference. If it looks like a zsock_t instance, return
283       //  the underlying libzmq socket handle; else if it looks like a file
284       //  descriptor, return NULL; else if it looks like a libzmq socket handle,
285       //  return the supplied value. Takes a polymorphic socket reference.
286       CZMQ_EXPORT void *
287           zsock_resolve (void *self);
288
289       //  Get socket option `priority`.
290       //  Available from libzmq 4.3.0.
291       //  Caller owns return value and must destroy it when done.
292       CZMQ_EXPORT int
293           zsock_priority (void *self);
294
295       //  Set socket option `priority`.
296       //  Available from libzmq 4.3.0.
297       CZMQ_EXPORT void
298           zsock_set_priority (void *self, int priority);
299
300       //  Get socket option `reconnect_stop`.
301       //  Available from libzmq 4.3.0.
302       //  Caller owns return value and must destroy it when done.
303       CZMQ_EXPORT int
304           zsock_reconnect_stop (void *self);
305
306       //  Set socket option `reconnect_stop`.
307       //  Available from libzmq 4.3.0.
308       CZMQ_EXPORT void
309           zsock_set_reconnect_stop (void *self, int reconnect_stop);
310
311       //  Set socket option `only_first_subscribe`.
312       //  Available from libzmq 4.3.0.
313       CZMQ_EXPORT void
314           zsock_set_only_first_subscribe (void *self, int only_first_subscribe);
315
316       //  Set socket option `hello_msg`.
317       //  Available from libzmq 4.3.0.
318       CZMQ_EXPORT void
319           zsock_set_hello_msg (void *self, zframe_t *hello_msg);
320
321       //  Set socket option `disconnect_msg`.
322       //  Available from libzmq 4.3.0.
323       CZMQ_EXPORT void
324           zsock_set_disconnect_msg (void *self, zframe_t *disconnect_msg);
325
326       //  Set socket option `wss_trust_system`.
327       //  Available from libzmq 4.3.0.
328       CZMQ_EXPORT void
329           zsock_set_wss_trust_system (void *self, int wss_trust_system);
330
331       //  Set socket option `wss_hostname`.
332       //  Available from libzmq 4.3.0.
333       CZMQ_EXPORT void
334           zsock_set_wss_hostname (void *self, const char *wss_hostname);
335
336       //  Set socket option `wss_trust_pem`.
337       //  Available from libzmq 4.3.0.
338       CZMQ_EXPORT void
339           zsock_set_wss_trust_pem (void *self, const char *wss_trust_pem);
340
341       //  Set socket option `wss_cert_pem`.
342       //  Available from libzmq 4.3.0.
343       CZMQ_EXPORT void
344           zsock_set_wss_cert_pem (void *self, const char *wss_cert_pem);
345
346       //  Set socket option `wss_key_pem`.
347       //  Available from libzmq 4.3.0.
348       CZMQ_EXPORT void
349           zsock_set_wss_key_pem (void *self, const char *wss_key_pem);
350
351       //  Get socket option `out_batch_size`.
352       //  Available from libzmq 4.3.0.
353       //  Caller owns return value and must destroy it when done.
354       CZMQ_EXPORT int
355           zsock_out_batch_size (void *self);
356
357       //  Set socket option `out_batch_size`.
358       //  Available from libzmq 4.3.0.
359       CZMQ_EXPORT void
360           zsock_set_out_batch_size (void *self, int out_batch_size);
361
362       //  Get socket option `in_batch_size`.
363       //  Available from libzmq 4.3.0.
364       //  Caller owns return value and must destroy it when done.
365       CZMQ_EXPORT int
366           zsock_in_batch_size (void *self);
367
368       //  Set socket option `in_batch_size`.
369       //  Available from libzmq 4.3.0.
370       CZMQ_EXPORT void
371           zsock_set_in_batch_size (void *self, int in_batch_size);
372
373       //  Get socket option `socks_password`.
374       //  Available from libzmq 4.3.0.
375       //  Caller owns return value and must destroy it when done.
376       CZMQ_EXPORT char *
377           zsock_socks_password (void *self);
378
379       //  Set socket option `socks_password`.
380       //  Available from libzmq 4.3.0.
381       CZMQ_EXPORT void
382           zsock_set_socks_password (void *self, const char *socks_password);
383
384       //  Get socket option `socks_username`.
385       //  Available from libzmq 4.3.0.
386       //  Caller owns return value and must destroy it when done.
387       CZMQ_EXPORT char *
388           zsock_socks_username (void *self);
389
390       //  Set socket option `socks_username`.
391       //  Available from libzmq 4.3.0.
392       CZMQ_EXPORT void
393           zsock_set_socks_username (void *self, const char *socks_username);
394
395       //  Set socket option `xpub_manual_last_value`.
396       //  Available from libzmq 4.3.0.
397       CZMQ_EXPORT void
398           zsock_set_xpub_manual_last_value (void *self, int xpub_manual_last_value);
399
400       //  Get socket option `router_notify`.
401       //  Available from libzmq 4.3.0.
402       //  Caller owns return value and must destroy it when done.
403       CZMQ_EXPORT int
404           zsock_router_notify (void *self);
405
406       //  Set socket option `router_notify`.
407       //  Available from libzmq 4.3.0.
408       CZMQ_EXPORT void
409           zsock_set_router_notify (void *self, int router_notify);
410
411       //  Get socket option `multicast_loop`.
412       //  Available from libzmq 4.3.0.
413       //  Caller owns return value and must destroy it when done.
414       CZMQ_EXPORT int
415           zsock_multicast_loop (void *self);
416
417       //  Set socket option `multicast_loop`.
418       //  Available from libzmq 4.3.0.
419       CZMQ_EXPORT void
420           zsock_set_multicast_loop (void *self, int multicast_loop);
421
422       //  Get socket option `metadata`.
423       //  Available from libzmq 4.3.0.
424       //  Caller owns return value and must destroy it when done.
425       CZMQ_EXPORT char *
426           zsock_metadata (void *self);
427
428       //  Set socket option `metadata`.
429       //  Available from libzmq 4.3.0.
430       CZMQ_EXPORT void
431           zsock_set_metadata (void *self, const char *metadata);
432
433       //  Get socket option `loopback_fastpath`.
434       //  Available from libzmq 4.3.0.
435       //  Caller owns return value and must destroy it when done.
436       CZMQ_EXPORT int
437           zsock_loopback_fastpath (void *self);
438
439       //  Set socket option `loopback_fastpath`.
440       //  Available from libzmq 4.3.0.
441       CZMQ_EXPORT void
442           zsock_set_loopback_fastpath (void *self, int loopback_fastpath);
443
444       //  Get socket option `zap_enforce_domain`.
445       //  Available from libzmq 4.3.0.
446       //  Caller owns return value and must destroy it when done.
447       CZMQ_EXPORT int
448           zsock_zap_enforce_domain (void *self);
449
450       //  Set socket option `zap_enforce_domain`.
451       //  Available from libzmq 4.3.0.
452       CZMQ_EXPORT void
453           zsock_set_zap_enforce_domain (void *self, int zap_enforce_domain);
454
455       //  Get socket option `gssapi_principal_nametype`.
456       //  Available from libzmq 4.3.0.
457       //  Caller owns return value and must destroy it when done.
458       CZMQ_EXPORT int
459           zsock_gssapi_principal_nametype (void *self);
460
461       //  Set socket option `gssapi_principal_nametype`.
462       //  Available from libzmq 4.3.0.
463       CZMQ_EXPORT void
464           zsock_set_gssapi_principal_nametype (void *self, int gssapi_principal_nametype);
465
466       //  Get socket option `gssapi_service_principal_nametype`.
467       //  Available from libzmq 4.3.0.
468       //  Caller owns return value and must destroy it when done.
469       CZMQ_EXPORT int
470           zsock_gssapi_service_principal_nametype (void *self);
471
472       //  Set socket option `gssapi_service_principal_nametype`.
473       //  Available from libzmq 4.3.0.
474       CZMQ_EXPORT void
475           zsock_set_gssapi_service_principal_nametype (void *self, int gssapi_service_principal_nametype);
476
477       //  Get socket option `bindtodevice`.
478       //  Available from libzmq 4.3.0.
479       //  Caller owns return value and must destroy it when done.
480       CZMQ_EXPORT char *
481           zsock_bindtodevice (void *self);
482
483       //  Set socket option `bindtodevice`.
484       //  Available from libzmq 4.3.0.
485       CZMQ_EXPORT void
486           zsock_set_bindtodevice (void *self, const char *bindtodevice);
487
488       //  Get socket option `heartbeat_ivl`.
489       //  Available from libzmq 4.2.0.
490       //  Caller owns return value and must destroy it when done.
491       CZMQ_EXPORT int
492           zsock_heartbeat_ivl (void *self);
493
494       //  Set socket option `heartbeat_ivl`.
495       //  Available from libzmq 4.2.0.
496       CZMQ_EXPORT void
497           zsock_set_heartbeat_ivl (void *self, int heartbeat_ivl);
498
499       //  Get socket option `heartbeat_ttl`.
500       //  Available from libzmq 4.2.0.
501       //  Caller owns return value and must destroy it when done.
502       CZMQ_EXPORT int
503           zsock_heartbeat_ttl (void *self);
504
505       //  Set socket option `heartbeat_ttl`.
506       //  Available from libzmq 4.2.0.
507       CZMQ_EXPORT void
508           zsock_set_heartbeat_ttl (void *self, int heartbeat_ttl);
509
510       //  Get socket option `heartbeat_timeout`.
511       //  Available from libzmq 4.2.0.
512       //  Caller owns return value and must destroy it when done.
513       CZMQ_EXPORT int
514           zsock_heartbeat_timeout (void *self);
515
516       //  Set socket option `heartbeat_timeout`.
517       //  Available from libzmq 4.2.0.
518       CZMQ_EXPORT void
519           zsock_set_heartbeat_timeout (void *self, int heartbeat_timeout);
520
521       //  Get socket option `use_fd`.
522       //  Available from libzmq 4.2.0.
523       //  Caller owns return value and must destroy it when done.
524       CZMQ_EXPORT int
525           zsock_use_fd (void *self);
526
527       //  Set socket option `use_fd`.
528       //  Available from libzmq 4.2.0.
529       CZMQ_EXPORT void
530           zsock_set_use_fd (void *self, int use_fd);
531
532       //  Set socket option `xpub_manual`.
533       //  Available from libzmq 4.2.0.
534       CZMQ_EXPORT void
535           zsock_set_xpub_manual (void *self, int xpub_manual);
536
537       //  Set socket option `xpub_welcome_msg`.
538       //  Available from libzmq 4.2.0.
539       CZMQ_EXPORT void
540           zsock_set_xpub_welcome_msg (void *self, const char *xpub_welcome_msg);
541
542       //  Set socket option `stream_notify`.
543       //  Available from libzmq 4.2.0.
544       CZMQ_EXPORT void
545           zsock_set_stream_notify (void *self, int stream_notify);
546
547       //  Get socket option `invert_matching`.
548       //  Available from libzmq 4.2.0.
549       //  Caller owns return value and must destroy it when done.
550       CZMQ_EXPORT int
551           zsock_invert_matching (void *self);
552
553       //  Set socket option `invert_matching`.
554       //  Available from libzmq 4.2.0.
555       CZMQ_EXPORT void
556           zsock_set_invert_matching (void *self, int invert_matching);
557
558       //  Set socket option `xpub_verboser`.
559       //  Available from libzmq 4.2.0.
560       CZMQ_EXPORT void
561           zsock_set_xpub_verboser (void *self, int xpub_verboser);
562
563       //  Get socket option `connect_timeout`.
564       //  Available from libzmq 4.2.0.
565       //  Caller owns return value and must destroy it when done.
566       CZMQ_EXPORT int
567           zsock_connect_timeout (void *self);
568
569       //  Set socket option `connect_timeout`.
570       //  Available from libzmq 4.2.0.
571       CZMQ_EXPORT void
572           zsock_set_connect_timeout (void *self, int connect_timeout);
573
574       //  Get socket option `tcp_maxrt`.
575       //  Available from libzmq 4.2.0.
576       //  Caller owns return value and must destroy it when done.
577       CZMQ_EXPORT int
578           zsock_tcp_maxrt (void *self);
579
580       //  Set socket option `tcp_maxrt`.
581       //  Available from libzmq 4.2.0.
582       CZMQ_EXPORT void
583           zsock_set_tcp_maxrt (void *self, int tcp_maxrt);
584
585       //  Get socket option `thread_safe`.
586       //  Available from libzmq 4.2.0.
587       //  Caller owns return value and must destroy it when done.
588       CZMQ_EXPORT int
589           zsock_thread_safe (void *self);
590
591       //  Get socket option `multicast_maxtpdu`.
592       //  Available from libzmq 4.2.0.
593       //  Caller owns return value and must destroy it when done.
594       CZMQ_EXPORT int
595           zsock_multicast_maxtpdu (void *self);
596
597       //  Set socket option `multicast_maxtpdu`.
598       //  Available from libzmq 4.2.0.
599       CZMQ_EXPORT void
600           zsock_set_multicast_maxtpdu (void *self, int multicast_maxtpdu);
601
602       //  Get socket option `vmci_buffer_size`.
603       //  Available from libzmq 4.2.0.
604       //  Caller owns return value and must destroy it when done.
605       CZMQ_EXPORT int
606           zsock_vmci_buffer_size (void *self);
607
608       //  Set socket option `vmci_buffer_size`.
609       //  Available from libzmq 4.2.0.
610       CZMQ_EXPORT void
611           zsock_set_vmci_buffer_size (void *self, int vmci_buffer_size);
612
613       //  Get socket option `vmci_buffer_min_size`.
614       //  Available from libzmq 4.2.0.
615       //  Caller owns return value and must destroy it when done.
616       CZMQ_EXPORT int
617           zsock_vmci_buffer_min_size (void *self);
618
619       //  Set socket option `vmci_buffer_min_size`.
620       //  Available from libzmq 4.2.0.
621       CZMQ_EXPORT void
622           zsock_set_vmci_buffer_min_size (void *self, int vmci_buffer_min_size);
623
624       //  Get socket option `vmci_buffer_max_size`.
625       //  Available from libzmq 4.2.0.
626       //  Caller owns return value and must destroy it when done.
627       CZMQ_EXPORT int
628           zsock_vmci_buffer_max_size (void *self);
629
630       //  Set socket option `vmci_buffer_max_size`.
631       //  Available from libzmq 4.2.0.
632       CZMQ_EXPORT void
633           zsock_set_vmci_buffer_max_size (void *self, int vmci_buffer_max_size);
634
635       //  Get socket option `vmci_connect_timeout`.
636       //  Available from libzmq 4.2.0.
637       //  Caller owns return value and must destroy it when done.
638       CZMQ_EXPORT int
639           zsock_vmci_connect_timeout (void *self);
640
641       //  Set socket option `vmci_connect_timeout`.
642       //  Available from libzmq 4.2.0.
643       CZMQ_EXPORT void
644           zsock_set_vmci_connect_timeout (void *self, int vmci_connect_timeout);
645
646       //  Get socket option `tos`.
647       //  Available from libzmq 4.1.0.
648       //  Caller owns return value and must destroy it when done.
649       CZMQ_EXPORT int
650           zsock_tos (void *self);
651
652       //  Set socket option `tos`.
653       //  Available from libzmq 4.1.0.
654       CZMQ_EXPORT void
655           zsock_set_tos (void *self, int tos);
656
657       //  Set socket option `router_handover`.
658       //  Available from libzmq 4.1.0.
659       CZMQ_EXPORT void
660           zsock_set_router_handover (void *self, int router_handover);
661
662       //  Set socket option `connect_rid`.
663       //  Available from libzmq 4.1.0.
664       CZMQ_EXPORT void
665           zsock_set_connect_rid (void *self, const char *connect_rid);
666
667       //  Set socket option `connect_rid` from 32-octet binary
668       //  Available from libzmq 4.1.0.
669       CZMQ_EXPORT void
670           zsock_set_connect_rid_bin (void *self, const byte *connect_rid);
671
672       //  Get socket option `handshake_ivl`.
673       //  Available from libzmq 4.1.0.
674       //  Caller owns return value and must destroy it when done.
675       CZMQ_EXPORT int
676           zsock_handshake_ivl (void *self);
677
678       //  Set socket option `handshake_ivl`.
679       //  Available from libzmq 4.1.0.
680       CZMQ_EXPORT void
681           zsock_set_handshake_ivl (void *self, int handshake_ivl);
682
683       //  Get socket option `socks_proxy`.
684       //  Available from libzmq 4.1.0.
685       //  Caller owns return value and must destroy it when done.
686       CZMQ_EXPORT char *
687           zsock_socks_proxy (void *self);
688
689       //  Set socket option `socks_proxy`.
690       //  Available from libzmq 4.1.0.
691       CZMQ_EXPORT void
692           zsock_set_socks_proxy (void *self, const char *socks_proxy);
693
694       //  Set socket option `xpub_nodrop`.
695       //  Available from libzmq 4.1.0.
696       CZMQ_EXPORT void
697           zsock_set_xpub_nodrop (void *self, int xpub_nodrop);
698
699       //  Set socket option `router_mandatory`.
700       //  Available from libzmq 4.0.0.
701       CZMQ_EXPORT void
702           zsock_set_router_mandatory (void *self, int router_mandatory);
703
704       //  Set socket option `probe_router`.
705       //  Available from libzmq 4.0.0.
706       CZMQ_EXPORT void
707           zsock_set_probe_router (void *self, int probe_router);
708
709       //  Set socket option `req_relaxed`.
710       //  Available from libzmq 4.0.0.
711       CZMQ_EXPORT void
712           zsock_set_req_relaxed (void *self, int req_relaxed);
713
714       //  Set socket option `req_correlate`.
715       //  Available from libzmq 4.0.0.
716       CZMQ_EXPORT void
717           zsock_set_req_correlate (void *self, int req_correlate);
718
719       //  Set socket option `conflate`.
720       //  Available from libzmq 4.0.0.
721       CZMQ_EXPORT void
722           zsock_set_conflate (void *self, int conflate);
723
724       //  Get socket option `zap_domain`.
725       //  Available from libzmq 4.0.0.
726       //  Caller owns return value and must destroy it when done.
727       CZMQ_EXPORT char *
728           zsock_zap_domain (void *self);
729
730       //  Set socket option `zap_domain`.
731       //  Available from libzmq 4.0.0.
732       CZMQ_EXPORT void
733           zsock_set_zap_domain (void *self, const char *zap_domain);
734
735       //  Get socket option `mechanism`.
736       //  Available from libzmq 4.0.0.
737       //  Caller owns return value and must destroy it when done.
738       CZMQ_EXPORT int
739           zsock_mechanism (void *self);
740
741       //  Get socket option `plain_server`.
742       //  Available from libzmq 4.0.0.
743       //  Caller owns return value and must destroy it when done.
744       CZMQ_EXPORT int
745           zsock_plain_server (void *self);
746
747       //  Set socket option `plain_server`.
748       //  Available from libzmq 4.0.0.
749       CZMQ_EXPORT void
750           zsock_set_plain_server (void *self, int plain_server);
751
752       //  Get socket option `plain_username`.
753       //  Available from libzmq 4.0.0.
754       //  Caller owns return value and must destroy it when done.
755       CZMQ_EXPORT char *
756           zsock_plain_username (void *self);
757
758       //  Set socket option `plain_username`.
759       //  Available from libzmq 4.0.0.
760       CZMQ_EXPORT void
761           zsock_set_plain_username (void *self, const char *plain_username);
762
763       //  Get socket option `plain_password`.
764       //  Available from libzmq 4.0.0.
765       //  Caller owns return value and must destroy it when done.
766       CZMQ_EXPORT char *
767           zsock_plain_password (void *self);
768
769       //  Set socket option `plain_password`.
770       //  Available from libzmq 4.0.0.
771       CZMQ_EXPORT void
772           zsock_set_plain_password (void *self, const char *plain_password);
773
774       //  Get socket option `curve_server`.
775       //  Available from libzmq 4.0.0.
776       //  Caller owns return value and must destroy it when done.
777       CZMQ_EXPORT int
778           zsock_curve_server (void *self);
779
780       //  Set socket option `curve_server`.
781       //  Available from libzmq 4.0.0.
782       CZMQ_EXPORT void
783           zsock_set_curve_server (void *self, int curve_server);
784
785       //  Get socket option `curve_publickey`.
786       //  Available from libzmq 4.0.0.
787       //  Caller owns return value and must destroy it when done.
788       CZMQ_EXPORT char *
789           zsock_curve_publickey (void *self);
790
791       //  Set socket option `curve_publickey`.
792       //  Available from libzmq 4.0.0.
793       CZMQ_EXPORT void
794           zsock_set_curve_publickey (void *self, const char *curve_publickey);
795
796       //  Set socket option `curve_publickey` from 32-octet binary
797       //  Available from libzmq 4.0.0.
798       CZMQ_EXPORT void
799           zsock_set_curve_publickey_bin (void *self, const byte *curve_publickey);
800
801       //  Get socket option `curve_secretkey`.
802       //  Available from libzmq 4.0.0.
803       //  Caller owns return value and must destroy it when done.
804       CZMQ_EXPORT char *
805           zsock_curve_secretkey (void *self);
806
807       //  Set socket option `curve_secretkey`.
808       //  Available from libzmq 4.0.0.
809       CZMQ_EXPORT void
810           zsock_set_curve_secretkey (void *self, const char *curve_secretkey);
811
812       //  Set socket option `curve_secretkey` from 32-octet binary
813       //  Available from libzmq 4.0.0.
814       CZMQ_EXPORT void
815           zsock_set_curve_secretkey_bin (void *self, const byte *curve_secretkey);
816
817       //  Get socket option `curve_serverkey`.
818       //  Available from libzmq 4.0.0.
819       //  Caller owns return value and must destroy it when done.
820       CZMQ_EXPORT char *
821           zsock_curve_serverkey (void *self);
822
823       //  Set socket option `curve_serverkey`.
824       //  Available from libzmq 4.0.0.
825       CZMQ_EXPORT void
826           zsock_set_curve_serverkey (void *self, const char *curve_serverkey);
827
828       //  Set socket option `curve_serverkey` from 32-octet binary
829       //  Available from libzmq 4.0.0.
830       CZMQ_EXPORT void
831           zsock_set_curve_serverkey_bin (void *self, const byte *curve_serverkey);
832
833       //  Get socket option `gssapi_server`.
834       //  Available from libzmq 4.0.0.
835       //  Caller owns return value and must destroy it when done.
836       CZMQ_EXPORT int
837           zsock_gssapi_server (void *self);
838
839       //  Set socket option `gssapi_server`.
840       //  Available from libzmq 4.0.0.
841       CZMQ_EXPORT void
842           zsock_set_gssapi_server (void *self, int gssapi_server);
843
844       //  Get socket option `gssapi_plaintext`.
845       //  Available from libzmq 4.0.0.
846       //  Caller owns return value and must destroy it when done.
847       CZMQ_EXPORT int
848           zsock_gssapi_plaintext (void *self);
849
850       //  Set socket option `gssapi_plaintext`.
851       //  Available from libzmq 4.0.0.
852       CZMQ_EXPORT void
853           zsock_set_gssapi_plaintext (void *self, int gssapi_plaintext);
854
855       //  Get socket option `gssapi_principal`.
856       //  Available from libzmq 4.0.0.
857       //  Caller owns return value and must destroy it when done.
858       CZMQ_EXPORT char *
859           zsock_gssapi_principal (void *self);
860
861       //  Set socket option `gssapi_principal`.
862       //  Available from libzmq 4.0.0.
863       CZMQ_EXPORT void
864           zsock_set_gssapi_principal (void *self, const char *gssapi_principal);
865
866       //  Get socket option `gssapi_service_principal`.
867       //  Available from libzmq 4.0.0.
868       //  Caller owns return value and must destroy it when done.
869       CZMQ_EXPORT char *
870           zsock_gssapi_service_principal (void *self);
871
872       //  Set socket option `gssapi_service_principal`.
873       //  Available from libzmq 4.0.0.
874       CZMQ_EXPORT void
875           zsock_set_gssapi_service_principal (void *self, const char *gssapi_service_principal);
876
877       //  Get socket option `ipv6`.
878       //  Available from libzmq 4.0.0.
879       //  Caller owns return value and must destroy it when done.
880       CZMQ_EXPORT int
881           zsock_ipv6 (void *self);
882
883       //  Set socket option `ipv6`.
884       //  Available from libzmq 4.0.0.
885       CZMQ_EXPORT void
886           zsock_set_ipv6 (void *self, int ipv6);
887
888       //  Get socket option `immediate`.
889       //  Available from libzmq 4.0.0.
890       //  Caller owns return value and must destroy it when done.
891       CZMQ_EXPORT int
892           zsock_immediate (void *self);
893
894       //  Set socket option `immediate`.
895       //  Available from libzmq 4.0.0.
896       CZMQ_EXPORT void
897           zsock_set_immediate (void *self, int immediate);
898
899       //  Get socket option `sndhwm`.
900       //  Available from libzmq 3.0.0.
901       //  Caller owns return value and must destroy it when done.
902       CZMQ_EXPORT int
903           zsock_sndhwm (void *self);
904
905       //  Set socket option `sndhwm`.
906       //  Available from libzmq 3.0.0.
907       CZMQ_EXPORT void
908           zsock_set_sndhwm (void *self, int sndhwm);
909
910       //  Get socket option `rcvhwm`.
911       //  Available from libzmq 3.0.0.
912       //  Caller owns return value and must destroy it when done.
913       CZMQ_EXPORT int
914           zsock_rcvhwm (void *self);
915
916       //  Set socket option `rcvhwm`.
917       //  Available from libzmq 3.0.0.
918       CZMQ_EXPORT void
919           zsock_set_rcvhwm (void *self, int rcvhwm);
920
921       //  Get socket option `maxmsgsize`.
922       //  Available from libzmq 3.0.0.
923       //  Caller owns return value and must destroy it when done.
924       CZMQ_EXPORT int
925           zsock_maxmsgsize (void *self);
926
927       //  Set socket option `maxmsgsize`.
928       //  Available from libzmq 3.0.0.
929       CZMQ_EXPORT void
930           zsock_set_maxmsgsize (void *self, int maxmsgsize);
931
932       //  Get socket option `multicast_hops`.
933       //  Available from libzmq 3.0.0.
934       //  Caller owns return value and must destroy it when done.
935       CZMQ_EXPORT int
936           zsock_multicast_hops (void *self);
937
938       //  Set socket option `multicast_hops`.
939       //  Available from libzmq 3.0.0.
940       CZMQ_EXPORT void
941           zsock_set_multicast_hops (void *self, int multicast_hops);
942
943       //  Set socket option `xpub_verbose`.
944       //  Available from libzmq 3.0.0.
945       CZMQ_EXPORT void
946           zsock_set_xpub_verbose (void *self, int xpub_verbose);
947
948       //  Get socket option `tcp_keepalive`.
949       //  Available from libzmq 3.0.0.
950       //  Caller owns return value and must destroy it when done.
951       CZMQ_EXPORT int
952           zsock_tcp_keepalive (void *self);
953
954       //  Set socket option `tcp_keepalive`.
955       //  Available from libzmq 3.0.0.
956       CZMQ_EXPORT void
957           zsock_set_tcp_keepalive (void *self, int tcp_keepalive);
958
959       //  Get socket option `tcp_keepalive_idle`.
960       //  Available from libzmq 3.0.0.
961       //  Caller owns return value and must destroy it when done.
962       CZMQ_EXPORT int
963           zsock_tcp_keepalive_idle (void *self);
964
965       //  Set socket option `tcp_keepalive_idle`.
966       //  Available from libzmq 3.0.0.
967       CZMQ_EXPORT void
968           zsock_set_tcp_keepalive_idle (void *self, int tcp_keepalive_idle);
969
970       //  Get socket option `tcp_keepalive_cnt`.
971       //  Available from libzmq 3.0.0.
972       //  Caller owns return value and must destroy it when done.
973       CZMQ_EXPORT int
974           zsock_tcp_keepalive_cnt (void *self);
975
976       //  Set socket option `tcp_keepalive_cnt`.
977       //  Available from libzmq 3.0.0.
978       CZMQ_EXPORT void
979           zsock_set_tcp_keepalive_cnt (void *self, int tcp_keepalive_cnt);
980
981       //  Get socket option `tcp_keepalive_intvl`.
982       //  Available from libzmq 3.0.0.
983       //  Caller owns return value and must destroy it when done.
984       CZMQ_EXPORT int
985           zsock_tcp_keepalive_intvl (void *self);
986
987       //  Set socket option `tcp_keepalive_intvl`.
988       //  Available from libzmq 3.0.0.
989       CZMQ_EXPORT void
990           zsock_set_tcp_keepalive_intvl (void *self, int tcp_keepalive_intvl);
991
992       //  Get socket option `tcp_accept_filter`.
993       //  Available from libzmq 3.0.0.
994       //  Caller owns return value and must destroy it when done.
995       CZMQ_EXPORT char *
996           zsock_tcp_accept_filter (void *self);
997
998       //  Set socket option `tcp_accept_filter`.
999       //  Available from libzmq 3.0.0.
1000       CZMQ_EXPORT void
1001           zsock_set_tcp_accept_filter (void *self, const char *tcp_accept_filter);
1002
1003       //  Get socket option `last_endpoint`.
1004       //  Available from libzmq 3.0.0.
1005       //  Caller owns return value and must destroy it when done.
1006       CZMQ_EXPORT char *
1007           zsock_last_endpoint (void *self);
1008
1009       //  Set socket option `router_raw`.
1010       //  Available from libzmq 3.0.0.
1011       CZMQ_EXPORT void
1012           zsock_set_router_raw (void *self, int router_raw);
1013
1014       //  Get socket option `ipv4only`.
1015       //  Available from libzmq 3.0.0.
1016       //  Caller owns return value and must destroy it when done.
1017       CZMQ_EXPORT int
1018           zsock_ipv4only (void *self);
1019
1020       //  Set socket option `ipv4only`.
1021       //  Available from libzmq 3.0.0.
1022       CZMQ_EXPORT void
1023           zsock_set_ipv4only (void *self, int ipv4only);
1024
1025       //  Set socket option `delay_attach_on_connect`.
1026       //  Available from libzmq 3.0.0.
1027       CZMQ_EXPORT void
1028           zsock_set_delay_attach_on_connect (void *self, int delay_attach_on_connect);
1029
1030       //  Get socket option `hwm`.
1031       //  Available from libzmq 2.0.0 to 3.0.0.
1032       //  Caller owns return value and must destroy it when done.
1033       CZMQ_EXPORT int
1034           zsock_hwm (void *self);
1035
1036       //  Set socket option `hwm`.
1037       //  Available from libzmq 2.0.0 to 3.0.0.
1038       CZMQ_EXPORT void
1039           zsock_set_hwm (void *self, int hwm);
1040
1041       //  Get socket option `swap`.
1042       //  Available from libzmq 2.0.0 to 3.0.0.
1043       //  Caller owns return value and must destroy it when done.
1044       CZMQ_EXPORT int
1045           zsock_swap (void *self);
1046
1047       //  Set socket option `swap`.
1048       //  Available from libzmq 2.0.0 to 3.0.0.
1049       CZMQ_EXPORT void
1050           zsock_set_swap (void *self, int swap);
1051
1052       //  Get socket option `affinity`.
1053       //  Available from libzmq 2.0.0.
1054       //  Caller owns return value and must destroy it when done.
1055       CZMQ_EXPORT int
1056           zsock_affinity (void *self);
1057
1058       //  Set socket option `affinity`.
1059       //  Available from libzmq 2.0.0.
1060       CZMQ_EXPORT void
1061           zsock_set_affinity (void *self, int affinity);
1062
1063       //  Get socket option `identity`.
1064       //  Available from libzmq 2.0.0.
1065       //  Caller owns return value and must destroy it when done.
1066       CZMQ_EXPORT char *
1067           zsock_identity (void *self);
1068
1069       //  Set socket option `identity`.
1070       //  Available from libzmq 2.0.0.
1071       CZMQ_EXPORT void
1072           zsock_set_identity (void *self, const char *identity);
1073
1074       //  Get socket option `rate`.
1075       //  Available from libzmq 2.0.0.
1076       //  Caller owns return value and must destroy it when done.
1077       CZMQ_EXPORT int
1078           zsock_rate (void *self);
1079
1080       //  Set socket option `rate`.
1081       //  Available from libzmq 2.0.0.
1082       CZMQ_EXPORT void
1083           zsock_set_rate (void *self, int rate);
1084
1085       //  Get socket option `recovery_ivl`.
1086       //  Available from libzmq 2.0.0.
1087       //  Caller owns return value and must destroy it when done.
1088       CZMQ_EXPORT int
1089           zsock_recovery_ivl (void *self);
1090
1091       //  Set socket option `recovery_ivl`.
1092       //  Available from libzmq 2.0.0.
1093       CZMQ_EXPORT void
1094           zsock_set_recovery_ivl (void *self, int recovery_ivl);
1095
1096       //  Get socket option `recovery_ivl_msec`.
1097       //  Available from libzmq 2.0.0 to 3.0.0.
1098       //  Caller owns return value and must destroy it when done.
1099       CZMQ_EXPORT int
1100           zsock_recovery_ivl_msec (void *self);
1101
1102       //  Set socket option `recovery_ivl_msec`.
1103       //  Available from libzmq 2.0.0 to 3.0.0.
1104       CZMQ_EXPORT void
1105           zsock_set_recovery_ivl_msec (void *self, int recovery_ivl_msec);
1106
1107       //  Get socket option `mcast_loop`.
1108       //  Available from libzmq 2.0.0 to 3.0.0.
1109       //  Caller owns return value and must destroy it when done.
1110       CZMQ_EXPORT int
1111           zsock_mcast_loop (void *self);
1112
1113       //  Set socket option `mcast_loop`.
1114       //  Available from libzmq 2.0.0 to 3.0.0.
1115       CZMQ_EXPORT void
1116           zsock_set_mcast_loop (void *self, int mcast_loop);
1117
1118       //  Get socket option `rcvtimeo`.
1119       //  Available from libzmq 2.2.0.
1120       //  Caller owns return value and must destroy it when done.
1121       CZMQ_EXPORT int
1122           zsock_rcvtimeo (void *self);
1123
1124       //  Set socket option `rcvtimeo`.
1125       //  Available from libzmq 2.2.0.
1126       CZMQ_EXPORT void
1127           zsock_set_rcvtimeo (void *self, int rcvtimeo);
1128
1129       //  Get socket option `sndtimeo`.
1130       //  Available from libzmq 2.2.0.
1131       //  Caller owns return value and must destroy it when done.
1132       CZMQ_EXPORT int
1133           zsock_sndtimeo (void *self);
1134
1135       //  Set socket option `sndtimeo`.
1136       //  Available from libzmq 2.2.0.
1137       CZMQ_EXPORT void
1138           zsock_set_sndtimeo (void *self, int sndtimeo);
1139
1140       //  Get socket option `sndbuf`.
1141       //  Available from libzmq 2.0.0.
1142       //  Caller owns return value and must destroy it when done.
1143       CZMQ_EXPORT int
1144           zsock_sndbuf (void *self);
1145
1146       //  Set socket option `sndbuf`.
1147       //  Available from libzmq 2.0.0.
1148       CZMQ_EXPORT void
1149           zsock_set_sndbuf (void *self, int sndbuf);
1150
1151       //  Get socket option `rcvbuf`.
1152       //  Available from libzmq 2.0.0.
1153       //  Caller owns return value and must destroy it when done.
1154       CZMQ_EXPORT int
1155           zsock_rcvbuf (void *self);
1156
1157       //  Set socket option `rcvbuf`.
1158       //  Available from libzmq 2.0.0.
1159       CZMQ_EXPORT void
1160           zsock_set_rcvbuf (void *self, int rcvbuf);
1161
1162       //  Get socket option `linger`.
1163       //  Available from libzmq 2.0.0.
1164       //  Caller owns return value and must destroy it when done.
1165       CZMQ_EXPORT int
1166           zsock_linger (void *self);
1167
1168       //  Set socket option `linger`.
1169       //  Available from libzmq 2.0.0.
1170       CZMQ_EXPORT void
1171           zsock_set_linger (void *self, int linger);
1172
1173       //  Get socket option `reconnect_ivl`.
1174       //  Available from libzmq 2.0.0.
1175       //  Caller owns return value and must destroy it when done.
1176       CZMQ_EXPORT int
1177           zsock_reconnect_ivl (void *self);
1178
1179       //  Set socket option `reconnect_ivl`.
1180       //  Available from libzmq 2.0.0.
1181       CZMQ_EXPORT void
1182           zsock_set_reconnect_ivl (void *self, int reconnect_ivl);
1183
1184       //  Get socket option `reconnect_ivl_max`.
1185       //  Available from libzmq 2.0.0.
1186       //  Caller owns return value and must destroy it when done.
1187       CZMQ_EXPORT int
1188           zsock_reconnect_ivl_max (void *self);
1189
1190       //  Set socket option `reconnect_ivl_max`.
1191       //  Available from libzmq 2.0.0.
1192       CZMQ_EXPORT void
1193           zsock_set_reconnect_ivl_max (void *self, int reconnect_ivl_max);
1194
1195       //  Get socket option `backlog`.
1196       //  Available from libzmq 2.0.0.
1197       //  Caller owns return value and must destroy it when done.
1198       CZMQ_EXPORT int
1199           zsock_backlog (void *self);
1200
1201       //  Set socket option `backlog`.
1202       //  Available from libzmq 2.0.0.
1203       CZMQ_EXPORT void
1204           zsock_set_backlog (void *self, int backlog);
1205
1206       //  Set socket option `subscribe`.
1207       //  Available from libzmq 2.0.0.
1208       CZMQ_EXPORT void
1209           zsock_set_subscribe (void *self, const char *subscribe);
1210
1211       //  Set socket option `unsubscribe`.
1212       //  Available from libzmq 2.0.0.
1213       CZMQ_EXPORT void
1214           zsock_set_unsubscribe (void *self, const char *unsubscribe);
1215
1216       //  Get socket option `type`.
1217       //  Available from libzmq 2.0.0.
1218       //  Caller owns return value and must destroy it when done.
1219       CZMQ_EXPORT int
1220           zsock_type (void *self);
1221
1222       //  Get socket option `rcvmore`.
1223       //  Available from libzmq 2.0.0.
1224       //  Caller owns return value and must destroy it when done.
1225       CZMQ_EXPORT int
1226           zsock_rcvmore (void *self);
1227
1228       //  Get socket option `fd`.
1229       //  Available from libzmq 2.0.0.
1230       //  Caller owns return value and must destroy it when done.
1231       CZMQ_EXPORT SOCKET
1232           zsock_fd (void *self);
1233
1234       //  Get socket option `events`.
1235       //  Available from libzmq 2.0.0.
1236       //  Caller owns return value and must destroy it when done.
1237       CZMQ_EXPORT int
1238           zsock_events (void *self);
1239
1240       //  Self test of this class.
1241       CZMQ_EXPORT void
1242           zsock_test (bool verbose);
1243
1244       #ifdef CZMQ_BUILD_DRAFT_API
1245       //  *** Draft method, for development use, may change without warning ***
1246       //  Create a SERVER socket. Default action is bind.
1247       CZMQ_EXPORT zsock_t *
1248           zsock_new_server (const char *endpoint);
1249
1250       //  *** Draft method, for development use, may change without warning ***
1251       //  Create a CLIENT socket. Default action is connect.
1252       CZMQ_EXPORT zsock_t *
1253           zsock_new_client (const char *endpoint);
1254
1255       //  *** Draft method, for development use, may change without warning ***
1256       //  Create a RADIO socket. Default action is bind.
1257       CZMQ_EXPORT zsock_t *
1258           zsock_new_radio (const char *endpoint);
1259
1260       //  *** Draft method, for development use, may change without warning ***
1261       //  Create a DISH socket. Default action is connect.
1262       CZMQ_EXPORT zsock_t *
1263           zsock_new_dish (const char *endpoint);
1264
1265       //  *** Draft method, for development use, may change without warning ***
1266       //  Create a GATHER socket. Default action is bind.
1267       CZMQ_EXPORT zsock_t *
1268           zsock_new_gather (const char *endpoint);
1269
1270       //  *** Draft method, for development use, may change without warning ***
1271       //  Create a SCATTER socket. Default action is connect.
1272       CZMQ_EXPORT zsock_t *
1273           zsock_new_scatter (const char *endpoint);
1274
1275       //  *** Draft method, for development use, may change without warning ***
1276       //  Create a DGRAM (UDP) socket. Default action is bind.
1277       //  The endpoint is a string consisting of a
1278       //  'transport'`://` followed by an 'address'. As this is
1279       //  a UDP socket the 'transport' has to be 'udp'. The
1280       //  'address' specifies the ip address and port to
1281       //  bind to. For example:  udp://127.0.0.1:1234
1282       //  Note: To send to an endpoint over UDP you have to
1283       //  send a message with the destination endpoint address
1284       //  as a first message!
1285       CZMQ_EXPORT zsock_t *
1286           zsock_new_dgram (const char *endpoint);
1287
1288       //  *** Draft method, for development use, may change without warning ***
1289       //  Return socket routing ID if any. This returns 0 if the socket is not
1290       //  of type ZMQ_SERVER or if no request was already received on it.
1291       CZMQ_EXPORT uint32_t
1292           zsock_routing_id (zsock_t *self);
1293
1294       //  *** Draft method, for development use, may change without warning ***
1295       //  Set routing ID on socket. The socket MUST be of type ZMQ_SERVER.
1296       //  This will be used when sending messages on the socket via the zsock API.
1297       CZMQ_EXPORT void
1298           zsock_set_routing_id (zsock_t *self, uint32_t routing_id);
1299
1300       //  *** Draft method, for development use, may change without warning ***
1301       //  Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH.
1302       //  Returns 0 if OK, -1 if failed.
1303       CZMQ_EXPORT int
1304           zsock_join (void *self, const char *group);
1305
1306       //  *** Draft method, for development use, may change without warning ***
1307       //  Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH.
1308       //  Returns 0 if OK, -1 if failed.
1309       CZMQ_EXPORT int
1310           zsock_leave (void *self, const char *group);
1311
1312       //  *** Draft method, for development use, may change without warning ***
1313       //  Check whether the socket has available message to read.
1314       CZMQ_EXPORT bool
1315           zsock_has_in (void *self);
1316
1317       #endif // CZMQ_BUILD_DRAFT_API
1318       Please add '@interface' section in './../src/zsock.c'.
1319

DESCRIPTION

1321       The zsock class wraps the libzmq socket handle (a void *) with a proper
1322       structure that follows the CLASS rules for construction and
1323       destruction. Some zsock methods take a void * "polymorphic" reference,
1324       which can be either a zsock_t or a zactor_t reference, or a libzmq void
1325       *.
1326
1327       Please add @discuss section in ./../src/zsock.c.
1328

EXAMPLE

1330       From zsock_test method.
1331
1332           zsock_t *writer = zsock_new (ZMQ_PUSH);
1333           assert (writer);
1334           int port = zsock_bind (writer, "tcp://127.0.0.1:*");
1335           assert (port != -1);
1336           assert (zsock_resolve (writer) != writer);
1337           assert (streq (zsock_type_str (writer), "PUSH"));
1338
1339           int rc;
1340           #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0))
1341           //  Check unbind
1342           rc = zsock_unbind (writer, "tcp://127.0.0.1:%d", port);
1343           assert (rc == 0);
1344
1345           //  In some cases and especially when running under Valgrind, doing
1346           //  a bind immediately after an unbind causes an EADDRINUSE error.
1347           //  Even a short sleep allows the OS to release the port for reuse.
1348           zclock_sleep (100);
1349
1350           //  Bind again
1351           rc = zsock_bind (writer, "tcp://127.0.0.1:%d", port);
1352           assert (rc == port);
1353           char endpoint [40];
1354           sprintf (endpoint, "tcp://127.0.0.1:%d", port);
1355           assert (streq (zsock_endpoint (writer), endpoint));
1356           #endif
1357
1358           zsock_t *reader = zsock_new (ZMQ_PULL);
1359           assert (reader);
1360           rc = zsock_connect (reader, "tcp://127.0.0.1:%d", port);
1361           assert (rc != -1);
1362           assert (zsock_resolve (reader) != reader);
1363           assert (streq (zsock_type_str (reader), "PULL"));
1364
1365           //  Basic Hello, World
1366           zstr_send (writer, "Hello, World");
1367           zmsg_t *msg = zmsg_recv (reader);
1368           assert (msg);
1369           char *string = zmsg_popstr (msg);
1370           assert (streq (string, "Hello, World"));
1371           freen (string);
1372           zmsg_destroy (&msg);
1373
1374           //  Test resolve libzmq socket
1375           #if (ZMQ_VERSION >= ZMQ_MAKE_VERSION (3, 2, 0))
1376           void *zmq_ctx = zmq_ctx_new ();
1377           #else
1378           void *zmq_ctx = zmq_ctx_new (1);
1379           #endif
1380           assert (zmq_ctx);
1381           void *zmq_sock = zmq_socket (zmq_ctx, ZMQ_PUB);
1382           assert (zmq_sock);
1383           assert (zsock_resolve (zmq_sock) == zmq_sock);
1384           zmq_close (zmq_sock);
1385           zmq_ctx_term (zmq_ctx);
1386
1387           //  Test resolve zsock
1388           zsock_t *resolve = zsock_new_pub("@tcp://127.0.0.1:*");
1389           assert (resolve);
1390           assert (zsock_resolve (resolve) == resolve->handle);
1391           zsock_destroy (&resolve);
1392
1393           //  Test resolve FD
1394           SOCKET fd = zsock_fd (reader);
1395           assert (zsock_resolve ((void *) &fd) == NULL);
1396
1397           //  Test binding to ephemeral ports, sequential and random
1398           port = zsock_bind (writer, "tcp://127.0.0.1:*");
1399           assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST);
1400           port = zsock_bind (writer, "tcp://127.0.0.1:*[50000-]");
1401           assert (port >= 50000 && port <= DYNAMIC_LAST);
1402           port = zsock_bind (writer, "tcp://127.0.0.1:*[-50001]");
1403           assert (port >= DYNAMIC_FIRST && port <= 50001);
1404           port = zsock_bind (writer, "tcp://127.0.0.1:*[60000-60500]");
1405           assert (port >= 60000 && port <= 60500);
1406
1407           port = zsock_bind (writer, "tcp://127.0.0.1:!");
1408           assert (port >= DYNAMIC_FIRST && port <= DYNAMIC_LAST);
1409           port = zsock_bind (writer, "tcp://127.0.0.1:![50000-]");
1410           assert (port >= 50000 && port <= DYNAMIC_LAST);
1411           port = zsock_bind (writer, "tcp://127.0.0.1:![-50001]");
1412           assert (port >= DYNAMIC_FIRST && port <= 50001);
1413           port = zsock_bind (writer, "tcp://127.0.0.1:![60000-60500]");
1414           assert (port >= 60000 && port <= 60500);
1415
1416           //  Test zsock_attach method
1417           zsock_t *dealer = zsock_new (ZMQ_DEALER);
1418           assert (dealer);
1419           rc = zsock_attach (dealer, "@inproc://myendpoint,tcp://127.0.0.1:*,inproc://others", true);
1420           assert (rc == 0);
1421           rc = zsock_attach (dealer, "", false);
1422           assert (rc == 0);
1423           rc = zsock_attach (dealer, NULL, true);
1424           assert (rc == 0);
1425           rc = zsock_attach (dealer, ">a,@b, c,, ", false);
1426           assert (rc == -1);
1427           zsock_destroy (&dealer);
1428
1429           //  Test zsock_endpoint method
1430           rc = zsock_bind (writer, "inproc://test.%s", "writer");
1431           assert (rc == 0);
1432           assert (streq (zsock_endpoint (writer), "inproc://test.writer"));
1433
1434           //  Test error state when connecting to an invalid socket type
1435           //  ('txp://' instead of 'tcp://', typo intentional)
1436           rc = zsock_connect (reader, "txp://127.0.0.1:5560");
1437           assert (rc == -1);
1438
1439           //  Test signal/wait methods
1440           rc = zsock_signal (writer, 123);
1441           assert (rc == 0);
1442           rc = zsock_wait (reader);
1443           assert (rc == 123);
1444
1445           //  Test zsock_send/recv pictures
1446           uint8_t  number1 = 123;
1447           uint16_t number2 = 123 * 123;
1448           uint32_t number4 = 123 * 123;
1449           number4 *= 123;
1450           uint32_t number4_MAX = UINT32_MAX;
1451           uint64_t number8 = 123 * 123;
1452           number8 *= 123;
1453           number8 *= 123;
1454           uint64_t number8_MAX = UINT64_MAX;
1455
1456           zchunk_t *chunk = zchunk_new ("HELLO", 5);
1457           assert (chunk);
1458           zframe_t *frame = zframe_new ("WORLD", 5);
1459           assert (frame);
1460           zhashx_t *hash = zhashx_new ();
1461           assert (hash);
1462           #ifdef CZMQ_BUILD_DRAFT_API
1463           zlistx_t *list = zlistx_new ();
1464           assert (list);
1465           #endif
1466           zuuid_t *uuid = zuuid_new ();
1467           assert (uuid);
1468           zhashx_set_destructor (hash, (zhashx_destructor_fn *) zstr_free);
1469           zhashx_set_duplicator (hash, (zhashx_duplicator_fn *) strdup);
1470           zhashx_insert (hash, "1", "value A");
1471           zhashx_insert (hash, "2", "value B");
1472           #ifdef CZMQ_BUILD_DRAFT_API
1473           zlistx_set_destructor (list, (zlistx_destructor_fn *) zstr_free);
1474           zlistx_set_duplicator (list, (zlistx_duplicator_fn *) strdup);
1475           zlistx_add_end (list, "1");
1476           zlistx_add_end (list, "2");
1477           #endif
1478           char *original = "pointer";
1479
1480           //  Test zsock_recv into each supported type
1481           #ifdef CZMQ_BUILD_DRAFT_API
1482           zsock_send (writer, "i124488zsbcfUhlp",
1483           #else
1484           zsock_send (writer, "i124488zsbcfUhp",
1485           #endif
1486                       -12345, number1, number2, number4, number4_MAX,
1487                       number8, number8_MAX,
1488                       "This is a string", "ABCDE", 5,
1489           #ifdef CZMQ_BUILD_DRAFT_API
1490                       chunk, frame, uuid, hash, list, original);
1491           #else
1492                       chunk, frame, uuid, hash, original);
1493           #endif
1494           char *uuid_str = strdup (zuuid_str (uuid));
1495           zchunk_destroy (&chunk);
1496           zframe_destroy (&frame);
1497           zuuid_destroy (&uuid);
1498           zhashx_destroy (&hash);
1499           #ifdef CZMQ_BUILD_DRAFT_API
1500           zlistx_destroy (&list);
1501           #endif
1502
1503           int integer;
1504           byte *data;
1505           size_t size;
1506           char *pointer;
1507           number8_MAX = number8 = number4_MAX = number4 = number2 = number1 = 0ULL;
1508           #ifdef CZMQ_BUILD_DRAFT_API
1509           rc = zsock_recv (reader, "i124488zsbcfUhlp",
1510           #else
1511           rc = zsock_recv (reader, "i124488zsbcfUhp",
1512           #endif
1513                            &integer, &number1, &number2, &number4, &number4_MAX,
1514                            &number8, &number8_MAX, &string, &data, &size, &chunk,
1515           #ifdef CZMQ_BUILD_DRAFT_API
1516                            &frame, &uuid, &hash, &list, &pointer);
1517           #else
1518                            &frame, &uuid, &hash, &pointer);
1519           #endif
1520           assert (rc == 0);
1521           assert (integer == -12345);
1522           assert (number1 == 123);
1523           assert (number2 == 123 * 123);
1524           assert (number4 == 123 * 123 * 123);
1525           assert (number4_MAX == UINT32_MAX);
1526           assert (number8 == 123 * 123 * 123 * 123);
1527           assert (number8_MAX == UINT64_MAX);
1528           assert (streq (string, "This is a string"));
1529           assert (memcmp (data, "ABCDE", 5) == 0);
1530           assert (size == 5);
1531           assert (memcmp (zchunk_data (chunk), "HELLO", 5) == 0);
1532           assert (zchunk_size (chunk) == 5);
1533           assert (streq (uuid_str, zuuid_str (uuid)));
1534           assert (memcmp (zframe_data (frame), "WORLD", 5) == 0);
1535           assert (zframe_size (frame) == 5);
1536           char *value = (char *) zhashx_lookup (hash, "1");
1537           assert (streq (value, "value A"));
1538           value = (char *) zhashx_lookup (hash, "2");
1539           assert (streq (value, "value B"));
1540           #ifdef CZMQ_BUILD_DRAFT_API
1541           value = (char *) zlistx_first (list);
1542           assert (streq (value, "1"));
1543           value = (char *) zlistx_last (list);
1544           assert (streq (value, "2"));
1545           #endif
1546           assert (original == pointer);
1547           freen (string);
1548           freen (data);
1549           freen (uuid_str);
1550           zframe_destroy (&frame);
1551           zchunk_destroy (&chunk);
1552           zhashx_destroy (&hash);
1553           #ifdef CZMQ_BUILD_DRAFT_API
1554           zlistx_destroy (&list);
1555           #endif
1556           zuuid_destroy (&uuid);
1557
1558           //  Test zsock_recv of short message; this lets us return a failure
1559           //  with a status code and then nothing else; the receiver will get
1560           //  the status code and NULL/zero for all other values
1561           zsock_send (writer, "i", -1);
1562           zsock_recv (reader, "izsbcfp",
1563               &integer, &string, &data, &size, &chunk, &frame, &pointer);
1564           assert (integer == -1);
1565           assert (string == NULL);
1566           assert (data == NULL);
1567           assert (size == 0);
1568           assert (chunk == NULL);
1569           assert (frame == NULL);
1570           assert (pointer == NULL);
1571
1572           msg = zmsg_new ();
1573           zmsg_addstr (msg, "frame 1");
1574           zmsg_addstr (msg, "frame 2");
1575           zsock_send (writer, "szm", "header", msg);
1576           zmsg_destroy (&msg);
1577
1578           zsock_recv (reader, "szm", &string, &msg);
1579
1580           assert (streq ("header", string));
1581           assert (zmsg_size (msg) == 2);
1582           assert (zframe_streq (zmsg_first (msg), "frame 1"));
1583           assert (zframe_streq (zmsg_next (msg), "frame 2"));
1584           zstr_free (&string);
1585           zmsg_destroy (&msg);
1586
1587           //  Test zsock_recv with null arguments
1588           chunk = zchunk_new ("HELLO", 5);
1589           assert (chunk);
1590           frame = zframe_new ("WORLD", 5);
1591           assert (frame);
1592           zsock_send (writer, "izsbcfp",
1593                       -12345, "This is a string", "ABCDE", 5, chunk, frame, original);
1594           zframe_destroy (&frame);
1595           zchunk_destroy (&chunk);
1596           zsock_recv (reader, "izsbcfp", &integer, NULL, NULL, NULL, &chunk, NULL, NULL);
1597           assert (integer == -12345);
1598           assert (memcmp (zchunk_data (chunk), "HELLO", 5) == 0);
1599           assert (zchunk_size (chunk) == 5);
1600           zchunk_destroy (&chunk);
1601
1602           //  Test zsock_bsend/brecv pictures with binary encoding
1603           frame = zframe_new ("Hello", 5);
1604           chunk = zchunk_new ("World", 5);
1605
1606           msg = zmsg_new ();
1607           zmsg_addstr (msg, "Hello");
1608           zmsg_addstr (msg, "World");
1609
1610           zsock_bsend (writer, "1248sSpcfm",
1611                        number1, number2, number4, number8,
1612                        "Hello, World",
1613                        "Goodbye cruel World!",
1614                        original,
1615                        chunk, frame, msg);
1616           zchunk_destroy (&chunk);
1617           zframe_destroy (&frame);
1618           zmsg_destroy (&msg);
1619
1620           number8 = number4 = number2 = number1 = 0;
1621           char *longstr;
1622           zsock_brecv (reader, "1248sSpcfm",
1623                        &number1, &number2, &number4, &number8,
1624                        &string, &longstr,
1625                        &pointer,
1626                        &chunk, &frame, &msg);
1627           assert (number1 == 123);
1628           assert (number2 == 123 * 123);
1629           assert (number4 == 123 * 123 * 123);
1630           assert (number8 == 123 * 123 * 123 * 123);
1631           assert (streq (string, "Hello, World"));
1632           assert (streq (longstr, "Goodbye cruel World!"));
1633           assert (pointer == original);
1634           zstr_free (&longstr);
1635           zchunk_destroy (&chunk);
1636           zframe_destroy (&frame);
1637           zmsg_destroy (&msg);
1638
1639           #ifdef ZMQ_SERVER
1640
1641           //  Test zsock_bsend/brecv pictures with binary encoding on SERVER and CLIENT sockets
1642           zsock_t *server = zsock_new (ZMQ_SERVER);
1643           assert (server);
1644           port = zsock_bind (server, "tcp://127.0.0.1:*");
1645           assert (port != -1);
1646           zsock_t* client = zsock_new (ZMQ_CLIENT);
1647           assert (client);
1648           rc = zsock_connect (client, "tcp://127.0.0.1:%d", port);
1649           assert (rc != -1);
1650
1651           //  From client to server
1652           chunk = zchunk_new ("World", 5);
1653           zsock_bsend (client, "1248sSpc",
1654                        number1, number2, number4, number8,
1655                        "Hello, World",
1656                        "Goodbye cruel World!",
1657                        original,
1658                        chunk);
1659           zchunk_destroy (&chunk);
1660
1661           number8 = number4 = number2 = number1 = 0;
1662           zsock_brecv (server, "1248sSpc",
1663                        &number1, &number2, &number4, &number8,
1664                        &string, &longstr,
1665                        &pointer,
1666                        &chunk);
1667           assert (number1 == 123);
1668           assert (number2 == 123 * 123);
1669           assert (number4 == 123 * 123 * 123);
1670           assert (number8 == 123 * 123 * 123 * 123);
1671           assert (streq (string, "Hello, World"));
1672           assert (streq (longstr, "Goodbye cruel World!"));
1673           assert (pointer == original);
1674           assert (zsock_routing_id (server));
1675           zstr_free (&longstr);
1676           zchunk_destroy (&chunk);
1677
1678           //  From server to client
1679           chunk = zchunk_new ("World", 5);
1680           zsock_bsend (server, "1248sSpc",
1681                        number1, number2, number4, number8,
1682                        "Hello, World",
1683                        "Goodbye cruel World!",
1684                        original,
1685                        chunk);
1686           zchunk_destroy (&chunk);
1687
1688           number8 = number4 = number2 = number1 = 0;
1689           zsock_brecv (client, "1248sSpc",
1690                        &number1, &number2, &number4, &number8,
1691                        &string, &longstr,
1692                        &pointer,
1693                        &chunk);
1694           assert (number1 == 123);
1695           assert (number2 == 123 * 123);
1696           assert (number4 == 123 * 123 * 123);
1697           assert (number8 == 123 * 123 * 123 * 123);
1698           assert (streq (string, "Hello, World"));
1699           assert (streq (longstr, "Goodbye cruel World!"));
1700           assert (pointer == original);
1701           assert (zsock_routing_id (client) == 0);
1702           zstr_free (&longstr);
1703           zchunk_destroy (&chunk);
1704
1705           zsock_destroy (&client);
1706           zsock_destroy (&server);
1707
1708           #else
1709           errno = 0;
1710           zsock_t* server = zsock_new_server (NULL);
1711           assert(server == NULL);
1712           assert(errno == ENOTSUP);
1713
1714           errno = 0;
1715           zsock_t* client = zsock_new_client (NULL);
1716           assert(client == NULL);
1717           assert(errno == ENOTSUP);
1718           #endif
1719
1720           #ifdef ZMQ_SCATTER
1721
1722           zsock_t* gather = zsock_new_gather ("inproc://test-gather-scatter");
1723           assert (gather);
1724           zsock_t* scatter = zsock_new_scatter ("inproc://test-gather-scatter");
1725           assert (scatter);
1726
1727           rc = zstr_send (scatter, "HELLO");
1728           assert (rc == 0);
1729
1730           char* message;
1731           message = zstr_recv (gather);
1732           assert (streq(message, "HELLO"));
1733           zstr_free (&message);
1734
1735           zsock_destroy (&gather);
1736           zsock_destroy (&scatter);
1737           #else
1738           errno = 0;
1739           zsock_t* scatter = zsock_new_scatter (NULL);
1740           assert(scatter == NULL);
1741           assert(errno == ENOTSUP);
1742
1743           errno = 0;
1744           zsock_t* gather = zsock_new_gather (NULL);
1745           assert(gather == NULL);
1746           assert(errno == ENOTSUP);
1747           #endif
1748
1749           #ifndef ZMQ_RADIO
1750           errno = 0;
1751           zsock_t* radio = zsock_new_radio (NULL);
1752           assert(radio == NULL);
1753           assert(errno == ENOTSUP);
1754
1755           errno = 0;
1756           zsock_t* dish = zsock_new_dish (NULL);
1757           assert(dish == NULL);
1758           assert(errno == ENOTSUP);
1759
1760           errno = 0;
1761           zsock_t* sock = zsock_new_req (NULL); // any supported socket type
1762           rc = zsock_join (sock, "group1");
1763           assert(rc == -1);
1764           assert(errno == ENOTSUP);
1765           errno = 0;
1766           rc = zsock_leave (sock, "group1");
1767           assert(rc == -1);
1768           assert(errno == ENOTSUP);
1769           zsock_destroy (&sock);
1770           #endif
1771
1772           //  Check that we can send a zproto format message
1773           zsock_bsend (writer, "1111sS4", 0xAA, 0xA0, 0x02, 0x01, "key", "value", 1234);
1774           zgossip_msg_t *gossip = zgossip_msg_new ();
1775           zgossip_msg_recv (gossip, reader);
1776           assert (zgossip_msg_id (gossip) == ZGOSSIP_MSG_PUBLISH);
1777           zgossip_msg_destroy (&gossip);
1778
1779           zsock_destroy (&reader);
1780           zsock_destroy (&writer);
1781
1782           #ifdef ZMQ_DGRAM
1783           // ZMQ_DGRAM ipv4 unicast test
1784           zsock_t* dgramr = zsock_new_dgram ("udp://*:7777");
1785           assert (dgramr);
1786           assert ( streq( "DGRAM", zsys_sockname(ZMQ_DGRAM)) );
1787           //zsock_t* dgrams = zsock_new_dgram ("udp://*:*");
1788           zsock_t* dgrams = zsock_new (ZMQ_DGRAM);
1789           zsock_bind (dgrams, "udp://127.0.0.1:7778" );
1790
1791           assert (dgrams);
1792           // perhaps sleep a little for sockets to setup?
1793
1794           rc = zstr_sendm( dgrams, "127.0.0.1:7777" );
1795           assert (rc == 0);
1796           rc = zstr_send (dgrams, "HELLO");
1797           assert (rc == 0);
1798
1799           char *dmessage, *addr;
1800
1801           zmsg_t *dmsg = zmsg_recv( dgramr );
1802           assert (dmsg);
1803           addr = zmsg_popstr (dmsg);
1804           dmessage = zmsg_popstr (dmsg);
1805           assert (streq(dmessage, "HELLO"));
1806           zmsg_destroy ( &dmsg );
1807           zsock_destroy (&dgrams);
1808           zsock_destroy (&dgramr);
1809           zstr_free (&dmessage);
1810           zstr_free (&addr);
1811           zstr_free (&message);
1812
1813           // ZMQ_DGRAM ipv4 multicast test
1814           zsock_t* mdgramr = zsock_new_dgram ("udp://225.25.25.25:7777");
1815           assert (mdgramr);
1816           zsock_t* mdgrams = zsock_new_dgram ("udp://*:*");
1817           assert (mdgrams);
1818
1819           rc = zstr_sendm( mdgrams, "225.25.25.25:7777" );
1820           assert (rc == 0);
1821           rc = zstr_send (mdgrams, "HELLO");
1822           assert (rc == 0);
1823
1824           char *mdmessage, *maddr;
1825
1826           zmsg_t *mdmsg = zmsg_recv( mdgramr );
1827           assert (mdmsg);
1828           maddr = zmsg_popstr (mdmsg);
1829           mdmessage = zmsg_popstr (mdmsg);
1830           assert (streq(mdmessage, "HELLO"));
1831           zmsg_destroy ( &mdmsg );
1832           zsock_destroy (&mdgrams);
1833           zsock_destroy (&mdgramr);
1834           zstr_free (&mdmessage);
1835           zstr_free (&maddr);
1836           zstr_free (&mdmessage);
1837
1838           //    // ipv6 (not supported yet)
1839           //    zsys_set_ipv6(1);
1840           //    zsock_t* dgramr6 = zsock_new_dgram ("udp://*:7777");
1841           //    assert (dgramr6);
1842           //    zsock_t* dgrams6 = zsock_new_dgram ("udp://*:*");
1843           //    assert (dgrams6);
1844           //    // perhaps sleep a little for sockets to setup?
1845           //    zclock_sleep(100);
1846
1847           //    rc = zstr_sendm( dgrams6, "::1:7777" );
1848           //    assert (rc == 0);
1849           //    rc = zstr_send (dgrams6, "HELLO");
1850           //    assert (rc == 0);
1851
1852           //    char *dmessage6, *addr6;
1853           //    zmsg_t *dmsg6 = zmsg_recv( dgramr6 );
1854           //    assert (dmsg6);
1855           //    addr6 = zmsg_popstr (dmsg6);
1856           //    dmessage6 = zmsg_popstr(dmsg6);
1857           //    assert (streq(dmessage6, "HELLO"));
1858           //    zmsg_destroy( &dmsg6 );
1859           //    zsock_destroy (&dgrams6);
1860           //    zsock_destroy (&dgramr6);
1861
1862           //    zstr_free (&dmessage6);
1863           //    zstr_free (&addr6);
1864           //    zstr_free (&dmessage6);
1865           #endif
1866
1867

AUTHORS

1869       The czmq manual was written by the authors in the AUTHORS file.
1870

RESOURCES

1872       Main web site:
1873
1874       Report bugs to the email <zeromq-dev@lists.zeromq.org[1]>
1875
1877       Copyright (c) the Contributors as noted in the AUTHORS file. This file
1878       is part of CZMQ, the high-level C binding for 0MQ:
1879       http://czmq.zeromq.org. This Source Code Form is subject to the terms
1880       of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
1881       distributed with this file, You can obtain one at
1882       http://mozilla.org/MPL/2.0/. LICENSE included with the czmq
1883       distribution.
1884

NOTES

1886        1. zeromq-dev@lists.zeromq.org
1887           mailto:zeromq-dev@lists.zeromq.org
1888
1889
1890
1891CZMQ 4.2.1                        01/19/2023                          ZSOCK(3)
Impressum