libzmq  master
ZeroMQ C++ Core Engine (LIBZMQ)
zmq.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file
3 
4  This file is part of libzmq, the ZeroMQ core engine in C++.
5 
6  libzmq is free software; you can redistribute it and/or modify it under
7  the terms of the GNU Lesser General Public License (LGPL) as published
8  by the Free Software Foundation; either version 3 of the License, or
9  (at your option) any later version.
10 
11  As a special exception, the Contributors give you permission to link
12  this library with independent modules to produce an executable,
13  regardless of the license terms of these independent modules, and to
14  copy and distribute the resulting executable under terms of your choice,
15  provided that you also meet, for each linked independent module, the
16  terms and conditions of the license of that module. An independent
17  module is a module which is not derived from or based on this library.
18  If you modify this library, you must extend this exception to your
19  version of the library.
20 
21  libzmq is distributed in the hope that it will be useful, but WITHOUT
22  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
24  License for more details.
25 
26  You should have received a copy of the GNU Lesser General Public License
27  along with this program. If not, see <http://www.gnu.org/licenses/>.
28 
29  *************************************************************************
30  NOTE to contributors. This file comprises the principal public contract
31  for ZeroMQ API users. Any change to this file supplied in a stable
32  release SHOULD not break existing applications.
33  In practice this means that the value of constants must not change, and
34  that old values may not be reused for new constants.
35  *************************************************************************
36 */
37 
38 #ifndef __ZMQ_H_INCLUDED__
39 #define __ZMQ_H_INCLUDED__
40 
41 /* Version macros for compile-time API version detection */
42 #define ZMQ_VERSION_MAJOR 4
43 #define ZMQ_VERSION_MINOR 2
44 #define ZMQ_VERSION_PATCH 0
45 
46 #define ZMQ_MAKE_VERSION(major, minor, patch) \
47  ((major) * 10000 + (minor) * 100 + (patch))
48 #define ZMQ_VERSION \
49  ZMQ_MAKE_VERSION(ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH)
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 #if !defined _WIN32_WCE
56 #include <errno.h>
57 #endif
58 #include <stddef.h>
59 #include <stdio.h>
60 #if defined _WIN32
61 #include <winsock2.h>
62 #endif
63 
64 /* Handle DSO symbol visibility */
65 #if defined _WIN32
66 # if defined ZMQ_STATIC
67 # define ZMQ_EXPORT
68 # elif defined DLL_EXPORT
69 # define ZMQ_EXPORT __declspec(dllexport)
70 # else
71 # define ZMQ_EXPORT __declspec(dllimport)
72 # endif
73 #else
74 # if defined __SUNPRO_C || defined __SUNPRO_CC
75 # define ZMQ_EXPORT __global
76 # elif (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER
77 # define ZMQ_EXPORT __attribute__ ((visibility("default")))
78 # else
79 # define ZMQ_EXPORT
80 # endif
81 #endif
82 
83 /* Define integer types needed for event interface */
84 #define ZMQ_DEFINED_STDINT 1
85 #if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_OPENVMS
86 # include <inttypes.h>
87 #elif defined _MSC_VER && _MSC_VER < 1600
88 # ifndef int32_t
89  typedef __int32 int32_t;
90 # endif
91 # ifndef uint16_t
92  typedef unsigned __int16 uint16_t;
93 # endif
94 # ifndef uint8_t
95  typedef unsigned __int8 uint8_t;
96 # endif
97 #else
98 # include <stdint.h>
99 #endif
100 
101 
102 /******************************************************************************/
103 /* 0MQ errors. */
104 /******************************************************************************/
105 
106 /* A number random enough not to collide with different errno ranges on */
107 /* different OSes. The assumption is that error_t is at least 32-bit type. */
108 #define ZMQ_HAUSNUMERO 156384712
109 
110 /* On Windows platform some of the standard POSIX errnos are not defined. */
111 #ifndef ENOTSUP
112 #define ENOTSUP (ZMQ_HAUSNUMERO + 1)
113 #endif
114 #ifndef EPROTONOSUPPORT
115 #define EPROTONOSUPPORT (ZMQ_HAUSNUMERO + 2)
116 #endif
117 #ifndef ENOBUFS
118 #define ENOBUFS (ZMQ_HAUSNUMERO + 3)
119 #endif
120 #ifndef ENETDOWN
121 #define ENETDOWN (ZMQ_HAUSNUMERO + 4)
122 #endif
123 #ifndef EADDRINUSE
124 #define EADDRINUSE (ZMQ_HAUSNUMERO + 5)
125 #endif
126 #ifndef EADDRNOTAVAIL
127 #define EADDRNOTAVAIL (ZMQ_HAUSNUMERO + 6)
128 #endif
129 #ifndef ECONNREFUSED
130 #define ECONNREFUSED (ZMQ_HAUSNUMERO + 7)
131 #endif
132 #ifndef EINPROGRESS
133 #define EINPROGRESS (ZMQ_HAUSNUMERO + 8)
134 #endif
135 #ifndef ENOTSOCK
136 #define ENOTSOCK (ZMQ_HAUSNUMERO + 9)
137 #endif
138 #ifndef EMSGSIZE
139 #define EMSGSIZE (ZMQ_HAUSNUMERO + 10)
140 #endif
141 #ifndef EAFNOSUPPORT
142 #define EAFNOSUPPORT (ZMQ_HAUSNUMERO + 11)
143 #endif
144 #ifndef ENETUNREACH
145 #define ENETUNREACH (ZMQ_HAUSNUMERO + 12)
146 #endif
147 #ifndef ECONNABORTED
148 #define ECONNABORTED (ZMQ_HAUSNUMERO + 13)
149 #endif
150 #ifndef ECONNRESET
151 #define ECONNRESET (ZMQ_HAUSNUMERO + 14)
152 #endif
153 #ifndef ENOTCONN
154 #define ENOTCONN (ZMQ_HAUSNUMERO + 15)
155 #endif
156 #ifndef ETIMEDOUT
157 #define ETIMEDOUT (ZMQ_HAUSNUMERO + 16)
158 #endif
159 #ifndef EHOSTUNREACH
160 #define EHOSTUNREACH (ZMQ_HAUSNUMERO + 17)
161 #endif
162 #ifndef ENETRESET
163 #define ENETRESET (ZMQ_HAUSNUMERO + 18)
164 #endif
165 
166 /* Native 0MQ error codes. */
167 #define EFSM (ZMQ_HAUSNUMERO + 51)
168 #define ENOCOMPATPROTO (ZMQ_HAUSNUMERO + 52)
169 #define ETERM (ZMQ_HAUSNUMERO + 53)
170 #define EMTHREAD (ZMQ_HAUSNUMERO + 54)
171 
172 /* This function retrieves the errno as it is known to 0MQ library. The goal */
173 /* of this function is to make the code 100% portable, including where 0MQ */
174 /* compiled with certain CRT library (on Windows) is linked to an */
175 /* application that uses different CRT library. */
176 ZMQ_EXPORT int zmq_errno (void);
177 
178 /* Resolves system errors and 0MQ errors to human-readable string. */
179 ZMQ_EXPORT const char *zmq_strerror (int errnum);
180 
181 /* Run-time API version detection */
182 ZMQ_EXPORT void zmq_version (int *major, int *minor, int *patch);
183 
184 /******************************************************************************/
185 /* 0MQ infrastructure (a.k.a. context) initialisation & termination. */
186 /******************************************************************************/
187 
188 /* Context options */
189 #define ZMQ_IO_THREADS 1
190 #define ZMQ_MAX_SOCKETS 2
191 #define ZMQ_SOCKET_LIMIT 3
192 #define ZMQ_THREAD_PRIORITY 3
193 #define ZMQ_THREAD_SCHED_POLICY 4
194 #define ZMQ_MAX_MSGSZ 5
195 
196 /* Default for new contexts */
197 #define ZMQ_IO_THREADS_DFLT 1
198 #define ZMQ_MAX_SOCKETS_DFLT 1023
199 #define ZMQ_THREAD_PRIORITY_DFLT -1
200 #define ZMQ_THREAD_SCHED_POLICY_DFLT -1
201 
202 ZMQ_EXPORT void *zmq_ctx_new (void);
203 ZMQ_EXPORT int zmq_ctx_term (void *context);
204 ZMQ_EXPORT int zmq_ctx_shutdown (void *context);
205 ZMQ_EXPORT int zmq_ctx_set (void *context, int option, int optval);
206 ZMQ_EXPORT int zmq_ctx_get (void *context, int option);
207 
208 /* Old (legacy) API */
209 ZMQ_EXPORT void *zmq_init (int io_threads);
210 ZMQ_EXPORT int zmq_term (void *context);
211 ZMQ_EXPORT int zmq_ctx_destroy (void *context);
212 
213 
214 /******************************************************************************/
215 /* 0MQ message definition. */
216 /******************************************************************************/
217 
218 /* union here ensures correct alignment on architectures that require it, e.g.
219  * SPARC
220  */
221 typedef union zmq_msg_t {unsigned char _ [64]; void *p; } zmq_msg_t;
222 
223 typedef void (zmq_free_fn) (void *data, void *hint);
224 
226 ZMQ_EXPORT int zmq_msg_init_size (zmq_msg_t *msg, size_t size);
227 ZMQ_EXPORT int zmq_msg_init_data (zmq_msg_t *msg, void *data,
228  size_t size, zmq_free_fn *ffn, void *hint);
229 ZMQ_EXPORT int zmq_msg_send (zmq_msg_t *msg, void *s, int flags);
230 ZMQ_EXPORT int zmq_msg_recv (zmq_msg_t *msg, void *s, int flags);
232 ZMQ_EXPORT int zmq_msg_move (zmq_msg_t *dest, zmq_msg_t *src);
233 ZMQ_EXPORT int zmq_msg_copy (zmq_msg_t *dest, zmq_msg_t *src);
234 ZMQ_EXPORT void *zmq_msg_data (zmq_msg_t *msg);
235 ZMQ_EXPORT size_t zmq_msg_size (zmq_msg_t *msg);
237 ZMQ_EXPORT int zmq_msg_get (zmq_msg_t *msg, int property);
238 ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int property, int optval);
239 ZMQ_EXPORT const char *zmq_msg_gets (zmq_msg_t *msg, const char *property);
240 
241 /******************************************************************************/
242 /* 0MQ socket definition. */
243 /******************************************************************************/
244 
245 /* Socket types. */
246 #define ZMQ_PAIR 0
247 #define ZMQ_PUB 1
248 #define ZMQ_SUB 2
249 #define ZMQ_REQ 3
250 #define ZMQ_REP 4
251 #define ZMQ_DEALER 5
252 #define ZMQ_ROUTER 6
253 #define ZMQ_PULL 7
254 #define ZMQ_PUSH 8
255 #define ZMQ_XPUB 9
256 #define ZMQ_XSUB 10
257 #define ZMQ_STREAM 11
258 
259 /* Deprecated aliases */
260 #define ZMQ_XREQ ZMQ_DEALER
261 #define ZMQ_XREP ZMQ_ROUTER
262 
263 /* Socket options. */
264 #define ZMQ_AFFINITY 4
265 #define ZMQ_IDENTITY 5
266 #define ZMQ_SUBSCRIBE 6
267 #define ZMQ_UNSUBSCRIBE 7
268 #define ZMQ_RATE 8
269 #define ZMQ_RECOVERY_IVL 9
270 #define ZMQ_SNDBUF 11
271 #define ZMQ_RCVBUF 12
272 #define ZMQ_RCVMORE 13
273 #define ZMQ_FD 14
274 #define ZMQ_EVENTS 15
275 #define ZMQ_TYPE 16
276 #define ZMQ_LINGER 17
277 #define ZMQ_RECONNECT_IVL 18
278 #define ZMQ_BACKLOG 19
279 #define ZMQ_RECONNECT_IVL_MAX 21
280 #define ZMQ_MAXMSGSIZE 22
281 #define ZMQ_SNDHWM 23
282 #define ZMQ_RCVHWM 24
283 #define ZMQ_MULTICAST_HOPS 25
284 #define ZMQ_RCVTIMEO 27
285 #define ZMQ_SNDTIMEO 28
286 #define ZMQ_LAST_ENDPOINT 32
287 #define ZMQ_ROUTER_MANDATORY 33
288 #define ZMQ_TCP_KEEPALIVE 34
289 #define ZMQ_TCP_KEEPALIVE_CNT 35
290 #define ZMQ_TCP_KEEPALIVE_IDLE 36
291 #define ZMQ_TCP_KEEPALIVE_INTVL 37
292 #define ZMQ_IMMEDIATE 39
293 #define ZMQ_XPUB_VERBOSE 40
294 #define ZMQ_ROUTER_RAW 41
295 #define ZMQ_IPV6 42
296 #define ZMQ_MECHANISM 43
297 #define ZMQ_PLAIN_SERVER 44
298 #define ZMQ_PLAIN_USERNAME 45
299 #define ZMQ_PLAIN_PASSWORD 46
300 #define ZMQ_CURVE_SERVER 47
301 #define ZMQ_CURVE_PUBLICKEY 48
302 #define ZMQ_CURVE_SECRETKEY 49
303 #define ZMQ_CURVE_SERVERKEY 50
304 #define ZMQ_PROBE_ROUTER 51
305 #define ZMQ_REQ_CORRELATE 52
306 #define ZMQ_REQ_RELAXED 53
307 #define ZMQ_CONFLATE 54
308 #define ZMQ_ZAP_DOMAIN 55
309 #define ZMQ_ROUTER_HANDOVER 56
310 #define ZMQ_TOS 57
311 #define ZMQ_CONNECT_RID 61
312 #define ZMQ_GSSAPI_SERVER 62
313 #define ZMQ_GSSAPI_PRINCIPAL 63
314 #define ZMQ_GSSAPI_SERVICE_PRINCIPAL 64
315 #define ZMQ_GSSAPI_PLAINTEXT 65
316 #define ZMQ_HANDSHAKE_IVL 66
317 #define ZMQ_SOCKS_PROXY 68
318 #define ZMQ_XPUB_NODROP 69
319 // All options after this is for version 4.2 and still *draft*
320 // Subject to arbitrary change without notice
321 #define ZMQ_BLOCKY 70
322 #define ZMQ_XPUB_MANUAL 71
323 #define ZMQ_XPUB_WELCOME_MSG 72
324 #define ZMQ_STREAM_NOTIFY 73
325 #define ZMQ_INVERT_MATCHING 74
326 #define ZMQ_HEARTBEAT_IVL 75
327 #define ZMQ_HEARTBEAT_TTL 76
328 #define ZMQ_HEARTBEAT_TIMEOUT 77
329 #define ZMQ_XPUB_VERBOSER 78
330 #define ZMQ_CONNECT_TIMEOUT 79
331 #define ZMQ_TCP_MAXRT 80
332 #define ZMQ_THREAD_SAFE 81
333 #define ZMQ_MULTICAST_MAXTPDU 84
334 #define ZMQ_VMCI_BUFFER_SIZE 85
335 #define ZMQ_VMCI_BUFFER_MIN_SIZE 86
336 #define ZMQ_VMCI_BUFFER_MAX_SIZE 87
337 #define ZMQ_VMCI_CONNECT_TIMEOUT 88
338 #define ZMQ_USE_FD 89
339 
340 /* Message options */
341 #define ZMQ_MORE 1
342 #define ZMQ_SHARED 3
343 
344 /* Send/recv options. */
345 #define ZMQ_DONTWAIT 1
346 #define ZMQ_SNDMORE 2
347 
348 /* Security mechanisms */
349 #define ZMQ_NULL 0
350 #define ZMQ_PLAIN 1
351 #define ZMQ_CURVE 2
352 #define ZMQ_GSSAPI 3
353 
354 /* RADIO-DISH protocol */
355 #define ZMQ_GROUP_MAX_LENGTH 15
356 
357 /* Deprecated options and aliases */
358 #define ZMQ_TCP_ACCEPT_FILTER 38
359 #define ZMQ_IPC_FILTER_PID 58
360 #define ZMQ_IPC_FILTER_UID 59
361 #define ZMQ_IPC_FILTER_GID 60
362 #define ZMQ_IPV4ONLY 31
363 #define ZMQ_DELAY_ATTACH_ON_CONNECT ZMQ_IMMEDIATE
364 #define ZMQ_NOBLOCK ZMQ_DONTWAIT
365 #define ZMQ_FAIL_UNROUTABLE ZMQ_ROUTER_MANDATORY
366 #define ZMQ_ROUTER_BEHAVIOR ZMQ_ROUTER_MANDATORY
367 
368 /* Deprecated Message options */
369 #define ZMQ_SRCFD 2
370 
371 /******************************************************************************/
372 /* 0MQ socket events and monitoring */
373 /******************************************************************************/
374 
375 /* Socket transport events (TCP, IPC and TIPC only) */
376 
377 #define ZMQ_EVENT_CONNECTED 0x0001
378 #define ZMQ_EVENT_CONNECT_DELAYED 0x0002
379 #define ZMQ_EVENT_CONNECT_RETRIED 0x0004
380 #define ZMQ_EVENT_LISTENING 0x0008
381 #define ZMQ_EVENT_BIND_FAILED 0x0010
382 #define ZMQ_EVENT_ACCEPTED 0x0020
383 #define ZMQ_EVENT_ACCEPT_FAILED 0x0040
384 #define ZMQ_EVENT_CLOSED 0x0080
385 #define ZMQ_EVENT_CLOSE_FAILED 0x0100
386 #define ZMQ_EVENT_DISCONNECTED 0x0200
387 #define ZMQ_EVENT_MONITOR_STOPPED 0x0400
388 #define ZMQ_EVENT_ALL 0xFFFF
389 
390 ZMQ_EXPORT void *zmq_socket (void *, int type);
391 ZMQ_EXPORT int zmq_close (void *s);
392 ZMQ_EXPORT int zmq_setsockopt (void *s, int option, const void *optval,
393  size_t optvallen);
394 ZMQ_EXPORT int zmq_getsockopt (void *s, int option, void *optval,
395  size_t *optvallen);
396 ZMQ_EXPORT int zmq_bind (void *s, const char *addr);
397 ZMQ_EXPORT int zmq_connect (void *s, const char *addr);
398 ZMQ_EXPORT int zmq_unbind (void *s, const char *addr);
399 ZMQ_EXPORT int zmq_disconnect (void *s, const char *addr);
400 ZMQ_EXPORT int zmq_send (void *s, const void *buf, size_t len, int flags);
401 ZMQ_EXPORT int zmq_send_const (void *s, const void *buf, size_t len, int flags);
402 ZMQ_EXPORT int zmq_recv (void *s, void *buf, size_t len, int flags);
403 ZMQ_EXPORT int zmq_socket_monitor (void *s, const char *addr, int events);
404 
405 
406 /******************************************************************************/
407 /* I/O multiplexing. */
408 /******************************************************************************/
409 
410 #define ZMQ_POLLIN 1
411 #define ZMQ_POLLOUT 2
412 #define ZMQ_POLLERR 4
413 #define ZMQ_POLLPRI 8
414 
415 typedef struct zmq_pollitem_t
416 {
417  void *socket;
418 #if defined _WIN32
419  SOCKET fd;
420 #else
421  int fd;
422 #endif
423  short events;
424  short revents;
426 
427 #define ZMQ_POLLITEMS_DFLT 16
428 
429 ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout);
430 
431 /******************************************************************************/
432 /* Message proxying */
433 /******************************************************************************/
434 
435 ZMQ_EXPORT int zmq_proxy (void *frontend, void *backend, void *capture);
436 ZMQ_EXPORT int zmq_proxy_steerable (void *frontend, void *backend, void *capture, void *control);
437 
438 /******************************************************************************/
439 /* Probe library capabilities */
440 /******************************************************************************/
441 
442 #define ZMQ_HAS_CAPABILITIES 1
443 ZMQ_EXPORT int zmq_has (const char *capability);
444 
445 /* Deprecated aliases */
446 #define ZMQ_STREAMER 1
447 #define ZMQ_FORWARDER 2
448 #define ZMQ_QUEUE 3
449 
450 /* Deprecated methods */
451 ZMQ_EXPORT int zmq_device (int type, void *frontend, void *backend);
452 ZMQ_EXPORT int zmq_sendmsg (void *s, zmq_msg_t *msg, int flags);
453 ZMQ_EXPORT int zmq_recvmsg (void *s, zmq_msg_t *msg, int flags);
454 struct iovec;
455 ZMQ_EXPORT int zmq_sendiov (void *s, struct iovec *iov, size_t count, int flags);
456 ZMQ_EXPORT int zmq_recviov (void *s, struct iovec *iov, size_t *count, int flags);
457 
458 /******************************************************************************/
459 /* Encryption functions */
460 /******************************************************************************/
461 
462 /* Encode data with Z85 encoding. Returns encoded data */
463 ZMQ_EXPORT char *zmq_z85_encode (char *dest, const uint8_t *data, size_t size);
464 
465 /* Decode data with Z85 encoding. Returns decoded data */
466 ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest, const char *string);
467 
468 /* Generate z85-encoded public and private keypair with libsodium. */
469 /* Returns 0 on success. */
470 ZMQ_EXPORT int zmq_curve_keypair (char *z85_public_key, char *z85_secret_key);
471 
472 /******************************************************************************/
473 /* Atomic utility methods */
474 /******************************************************************************/
475 
477 ZMQ_EXPORT void zmq_atomic_counter_set (void *counter, int value);
478 ZMQ_EXPORT int zmq_atomic_counter_inc (void *counter);
479 ZMQ_EXPORT int zmq_atomic_counter_dec (void *counter);
480 ZMQ_EXPORT int zmq_atomic_counter_value (void *counter);
481 ZMQ_EXPORT void zmq_atomic_counter_destroy (void **counter_p);
482 
483 
484 /******************************************************************************/
485 /* These functions are not documented by man pages -- use at your own risk. */
486 /* If you need these to be part of the formal ZMQ API, then (a) write a man */
487 /* page, and (b) write a test case in tests. */
488 /******************************************************************************/
489 
490 /* Helper functions are used by perf tests so that they don't have to care */
491 /* about minutiae of time-related functions on different OS platforms. */
492 
493 /* Starts the stopwatch. Returns the handle to the watch. */
494 ZMQ_EXPORT void *zmq_stopwatch_start (void);
495 
496 /* Stops the stopwatch. Returns the number of microseconds elapsed since */
497 /* the stopwatch was started. */
498 ZMQ_EXPORT unsigned long zmq_stopwatch_stop (void *watch_);
499 
500 /* Sleeps for specified number of seconds. */
501 ZMQ_EXPORT void zmq_sleep (int seconds_);
502 
503 typedef void (zmq_thread_fn) (void*);
504 
505 /* Start a thread. Returns a handle to the thread. */
506 ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn* func, void* arg);
507 
508 /* Wait for thread to complete then free up resources. */
509 ZMQ_EXPORT void zmq_threadclose (void* thread);
510 
511 
512 /******************************************************************************/
513 /* These functions are DRAFT and disabled in stable releases, and subject to */
514 /* change at ANY time until declared stable. */
515 /******************************************************************************/
516 
517 #ifdef ZMQ_BUILD_DRAFT_API
518 
519 /* DRAFT Socket types. */
520 #define ZMQ_SERVER 12
521 #define ZMQ_CLIENT 13
522 #define ZMQ_RADIO 14
523 #define ZMQ_DISH 15
524 #define ZMQ_GATHER 16
525 #define ZMQ_SCATTER 17
526 
527 /* DRAFT Socket methods. */
528 ZMQ_EXPORT int zmq_join (void *s, const char *group);
529 ZMQ_EXPORT int zmq_leave (void *s, const char *group);
530 
531 /* DRAFT Msg methods. */
532 ZMQ_EXPORT int zmq_msg_set_routing_id(zmq_msg_t *msg, uint32_t routing_id);
534 ZMQ_EXPORT int zmq_msg_set_group(zmq_msg_t *msg, const char *group);
535 ZMQ_EXPORT const char *zmq_msg_group(zmq_msg_t *msg);
536 
537 /******************************************************************************/
538 /* Poller polling on sockets,fd and thread-safe sockets */
539 /******************************************************************************/
540 
541 #define ZMQ_HAVE_POLLER
542 
543 typedef struct zmq_poller_event_t
544 {
545  void *socket;
546 #if defined _WIN32
547  SOCKET fd;
548 #else
549  int fd;
550 #endif
551  void *user_data;
552  short events;
554 
555 ZMQ_EXPORT void *zmq_poller_new (void);
556 ZMQ_EXPORT int zmq_poller_destroy (void **poller_p);
557 ZMQ_EXPORT int zmq_poller_add (void *poller, void *socket, void *user_data, short events);
558 ZMQ_EXPORT int zmq_poller_modify (void *poller, void *socket, short events);
559 ZMQ_EXPORT int zmq_poller_remove (void *poller, void *socket);
560 ZMQ_EXPORT int zmq_poller_wait (void *poller, zmq_poller_event_t *event, long timeout);
561 
562 #if defined _WIN32
563 ZMQ_EXPORT int zmq_poller_add_fd (void *poller, SOCKET fd, void *user_data, short events);
564 ZMQ_EXPORT int zmq_poller_modify_fd (void *poller, SOCKET fd, short events);
565 ZMQ_EXPORT int zmq_poller_remove_fd (void *poller, SOCKET fd);
566 #else
567 ZMQ_EXPORT int zmq_poller_add_fd (void *poller, int fd, void *user_data, short events);
568 ZMQ_EXPORT int zmq_poller_modify_fd (void *poller, int fd, short events);
569 ZMQ_EXPORT int zmq_poller_remove_fd (void *poller, int fd);
570 #endif
571 
572 /******************************************************************************/
573 /* Scheduling timers */
574 /******************************************************************************/
575 
576 #define ZMQ_HAVE_TIMERS
577 
578 typedef void (zmq_timer_fn)(int timer_id, void *arg);
579 
580 ZMQ_EXPORT void *zmq_timers_new (void);
581 ZMQ_EXPORT int zmq_timers_destroy (void **timers_p);
582 ZMQ_EXPORT int zmq_timers_add (void *timers, size_t interval, zmq_timer_fn handler, void *arg);
583 ZMQ_EXPORT int zmq_timers_cancel (void *timers, int timer_id);
584 ZMQ_EXPORT int zmq_timers_set_interval (void *timers, int timer_id, size_t interval);
585 ZMQ_EXPORT int zmq_timers_reset (void *timers, int timer_id);
586 ZMQ_EXPORT long zmq_timers_timeout (void *timers);
587 ZMQ_EXPORT int zmq_timers_execute (void *timers);
588 
589 #endif // ZMQ_BUILD_DRAFT_API
590 
591 
592 #undef ZMQ_EXPORT
593 
594 #ifdef __cplusplus
595 }
596 #endif
597 
598 #endif
#define size
ZMQ_EXPORT int zmq_recviov(void *s, struct iovec *iov, size_t *count, int flags)
Definition: zmq.cpp:557
int zmq_poller_remove_fd(void *poller, int fd)
Definition: zmq.cpp:1206
int zmq_poller_add_fd(void *poller, int fd, void *user_data, short events)
Definition: zmq.cpp:1143
ZMQ_EXPORT int zmq_setsockopt(void *s, int option, const void *optval, size_t optvallen)
Definition: zmq.cpp:265
int zmq_poller_add(void *poller, void *socket, void *user_data, short events)
Definition: zmq.cpp:1124
ZMQ_EXPORT int zmq_unbind(void *s, const char *addr)
Definition: zmq.cpp:343
uint32_t zmq_msg_routing_id(zmq_msg_t *msg)
Definition: zmq.cpp:715
short events
Definition: zmq.h:423
ZMQ_EXPORT int zmq_proxy(void *frontend, void *backend, void *capture)
Definition: zmq.cpp:1323
struct zmq_pollitem_t zmq_pollitem_t
ZMQ_EXPORT void * zmq_ctx_new(void)
Definition: zmq.cpp:115
void( zmq_thread_fn)(void *)
Definition: zmq.h:503
int capture(class zmq::socket_base_t *capture_, zmq::msg_t &msg_, int more_=0)
Definition: proxy.cpp:52
ZMQ_EXPORT int zmq_msg_init_data(zmq_msg_t *msg, void *data, size_t size, zmq_free_fn *ffn, void *hint)
Definition: zmq.cpp:623
ZMQ_EXPORT int zmq_term(void *context)
Definition: zmq.cpp:231
int zmq_timers_execute(void *timers)
Definition: zmq.cpp:1311
ZMQ_EXPORT void * zmq_init(int io_threads)
Definition: zmq.cpp:220
ZMQ_EXPORT int zmq_recvmsg(void *s, zmq_msg_t *msg, int flags)
Definition: zmq.cpp:501
ZMQ_EXPORT int zmq_msg_copy(zmq_msg_t *dest, zmq_msg_t *src)
Definition: zmq.cpp:661
int zmq_poller_wait(void *poller, zmq_poller_event_t *event, long timeout)
Definition: zmq.cpp:1218
ZMQ_EXPORT int zmq_device(int type, void *frontend, void *backend)
Definition: zmq.cpp:1350
ZMQ_EXPORT int zmq_recv(void *s, void *buf, size_t len, int flags)
Definition: zmq.cpp:507
ZMQ_EXPORT int zmq_errno(void)
Definition: zmq.cpp:107
ZMQ_EXPORT int zmq_send_const(void *s, const void *buf, size_t len, int flags)
Definition: zmq.cpp:416
void * socket
Definition: zmq.h:417
void handler(int timer_id, void *arg)
Definition: test_timers.cpp:43
ZMQ_EXPORT unsigned long zmq_stopwatch_stop(void *watch_)
Definition: zmq_utils.cpp:70
ZMQ_EXPORT void * zmq_msg_data(zmq_msg_t *msg)
Definition: zmq.cpp:666
ZMQ_EXPORT void * zmq_socket(void *, int type)
Definition: zmq.cpp:244
int zmq_timers_cancel(void *timers, int timer_id)
Definition: zmq.cpp:1271
ZMQ_EXPORT void zmq_version(int *major, int *minor, int *patch)
Definition: zmq.cpp:94
short revents
Definition: zmq.h:424
ZMQ_EXPORT int zmq_socket_monitor(void *s, const char *addr, int events)
Definition: zmq.cpp:288
int zmq_timers_destroy(void **timers_p)
Definition: zmq.cpp:1249
int fd
Definition: zmq.h:421
ZMQ_EXPORT void zmq_threadclose(void *thread)
Definition: zmq_utils.cpp:85
ZMQ_EXPORT int zmq_ctx_set(void *context, int option, int optval)
Definition: zmq.cpp:200
unsigned char _[64]
Definition: zmq.h:221
ZMQ_EXPORT int zmq_getsockopt(void *s, int option, void *optval, size_t *optvallen)
Definition: zmq.cpp:277
int zmq_timers_add(void *timers, size_t interval, zmq_timer_fn handler, void *arg)
Definition: zmq.cpp:1261
void * p
Definition: zmq.h:221
ZMQ_EXPORT int zmq_msg_send(zmq_msg_t *msg, void *s, int flags)
Definition: zmq.cpp:629
long zmq_timers_timeout(void *timers)
Definition: zmq.cpp:1301
ZMQ_EXPORT void zmq_atomic_counter_set(void *counter, int value)
Definition: zmq_utils.cpp:231
struct zmq_poller_event_t zmq_poller_event_t
void ffn(void *data, void *hint)
int zmq_timers_reset(void *timers, int timer_id)
Definition: zmq.cpp:1291
ZMQ_EXPORT int zmq_connect(void *s, const char *addr)
Definition: zmq.cpp:332
int zmq_join(void *s, const char *group)
Definition: zmq.cpp:299
ZMQ_EXPORT int zmq_close(void *s)
Definition: zmq.cpp:255
void * zmq_timers_new(void)
Definition: zmq.cpp:1242
ZMQ_EXPORT int zmq_atomic_counter_dec(void *counter)
Definition: zmq_utils.cpp:246
ZMQ_EXPORT int zmq_ctx_shutdown(void *context)
Definition: zmq.cpp:191
ZMQ_EXPORT int zmq_sendmsg(void *s, zmq_msg_t *msg, int flags)
Definition: zmq.cpp:382
ZMQ_EXPORT uint8_t * zmq_z85_decode(uint8_t *dest, const char *string)
Definition: zmq_utils.cpp:158
ZMQ_EXPORT int zmq_msg_recv(zmq_msg_t *msg, void *s, int flags)
Definition: zmq.cpp:640
ZMQ_EXPORT const char * zmq_strerror(int errnum)
Definition: zmq.cpp:102
ZMQ_EXPORT int zmq_msg_more(zmq_msg_t *msg)
Definition: zmq.cpp:676
int zmq_poller_modify(void *poller, void *socket, short events)
Definition: zmq.cpp:1155
ZMQ_EXPORT int zmq_ctx_destroy(void *context)
Definition: zmq.cpp:236
Definition: zmq.h:221
ZMQ_EXPORT int zmq_sendiov(void *s, struct iovec *iov, size_t count, int flags)
Definition: zmq.cpp:449
ZMQ_EXPORT void zmq_atomic_counter_destroy(void **counter_p)
Definition: zmq_utils.cpp:260
Definition: zmq.cpp:57
ZMQ_EXPORT int zmq_curve_keypair(char *z85_public_key, char *z85_secret_key)
Definition: zmq_utils.cpp:191
enum type_t type
ZMQ_EXPORT const char * zmq_msg_gets(zmq_msg_t *msg, const char *property)
Definition: zmq.cpp:732
void( zmq_free_fn)(void *data, void *hint)
Definition: zmq.h:223
int zmq_poller_remove(void *poller, void *socket)
Definition: zmq.cpp:1187
ZMQ_EXPORT int zmq_poll(zmq_pollitem_t *items, int nitems, long timeout)
Definition: zmq.cpp:748
ZMQ_EXPORT void zmq_sleep(int seconds_)
Definition: zmq_utils.cpp:53
const char * zmq_msg_group(zmq_msg_t *msg)
Definition: zmq.cpp:725
ZMQ_EXPORT int zmq_send(void *s, const void *buf, size_t len, int flags)
Definition: zmq.cpp:387
ZMQ_EXPORT int zmq_msg_get(zmq_msg_t *msg, int property)
Definition: zmq.cpp:681
int zmq_leave(void *s, const char *group)
Definition: zmq.cpp:310
ZMQ_EXPORT int zmq_bind(void *s, const char *addr)
Definition: zmq.cpp:321
ZMQ_EXPORT int zmq_atomic_counter_inc(void *counter)
Definition: zmq_utils.cpp:238
ZMQ_EXPORT int zmq_atomic_counter_value(void *counter)
Definition: zmq_utils.cpp:253
ZMQ_EXPORT int zmq_ctx_term(void *context)
Definition: zmq.cpp:162
ZMQ_EXPORT void * zmq_stopwatch_start(void)
Definition: zmq_utils.cpp:62
#define ZMQ_EXPORT
Definition: zmq.h:79
ZMQ_EXPORT int zmq_msg_set(zmq_msg_t *msg, int property, int optval)
Definition: zmq.cpp:703
ZMQ_EXPORT int zmq_msg_close(zmq_msg_t *msg)
Definition: zmq.cpp:651
ZMQ_EXPORT int zmq_ctx_get(void *context, int option)
Definition: zmq.cpp:209
ZMQ_EXPORT int zmq_msg_init_size(zmq_msg_t *msg, size_t size)
Definition: zmq.cpp:618
ZMQ_EXPORT void * zmq_threadstart(zmq_thread_fn *func, void *arg)
Definition: zmq_utils.cpp:78
ZMQ_EXPORT int zmq_has(const char *capability)
Definition: zmq.cpp:1359
int zmq_timers_set_interval(void *timers, int timer_id, size_t interval)
Definition: zmq.cpp:1281
ZMQ_EXPORT size_t zmq_msg_size(zmq_msg_t *msg)
Definition: zmq.cpp:671
int zmq_msg_set_group(zmq_msg_t *msg, const char *group)
Definition: zmq.cpp:720
ZMQ_EXPORT int zmq_disconnect(void *s, const char *addr)
Definition: zmq.cpp:353
ZMQ_EXPORT char * zmq_z85_encode(char *dest, const uint8_t *data, size_t size)
Definition: zmq_utils.cpp:124
int zmq_msg_set_routing_id(zmq_msg_t *msg, uint32_t routing_id)
Definition: zmq.cpp:710
union zmq_msg_t zmq_msg_t
ZMQ_EXPORT int zmq_proxy_steerable(void *frontend, void *backend, void *capture, void *control)
Definition: zmq.cpp:1335
int zmq_poller_modify_fd(void *poller, int fd, short events)
Definition: zmq.cpp:1175
ZMQ_EXPORT void * zmq_atomic_counter_new(void)
Definition: zmq_utils.cpp:222
ZMQ_EXPORT int zmq_msg_move(zmq_msg_t *dest, zmq_msg_t *src)
Definition: zmq.cpp:656
ZMQ_EXPORT int zmq_msg_init(zmq_msg_t *msg)
Definition: zmq.cpp:613
int zmq_poller_destroy(void **poller_p)
Definition: zmq.cpp:1111
void( zmq_timer_fn)(int timer_id, void *arg)
void * zmq_poller_new(void)
Definition: zmq.cpp:1104