├── .gitignore ├── C ├── AUTHORS ├── COPYING.LESSER ├── zmq.h └── zmq_utils.h ├── README.md ├── deimos └── zmq │ ├── utils.d │ └── zmq.d └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.a 3 | .dub/ 4 | *.lib 5 | -------------------------------------------------------------------------------- /C/AUTHORS: -------------------------------------------------------------------------------- 1 | Corporate Contributors 2 | ====================== 3 | 4 | Copyright (c) 2007-2014 iMatix Corporation 5 | Copyright (c) 2009-2011 250bpm s.r.o. 6 | Copyright (c) 2010-2011 Miru Limited 7 | Copyright (c) 2011 VMware, Inc. 8 | Copyright (c) 2012 Spotify AB 9 | Copyright (c) 2013 Ericsson AB 10 | Copyright (c) 2014 AppDynamics Inc. 11 | Copyright (c) 2015 Google, Inc. 12 | Copyright (c) 2015-2016 Brocade Communications Systems Inc. 13 | 14 | Individual Contributors 15 | ======================= 16 | 17 | AJ Lewis 18 | Alexej Lotz 19 | Andrew Thompson 20 | André Caron 21 | Asko Kauppi 22 | Attila Mark 23 | Barak Amar 24 | Ben Gray 25 | Bernd Melchers 26 | Bernd Prager 27 | Bob Beaty 28 | Brandon Carpenter 29 | Brett Cameron 30 | Brian Buchanan 31 | Burak Arslan 32 | Carl Clemens 33 | Chia-liang Kao 34 | Chris Busbey 35 | Chris Rempel 36 | Chris Wong 37 | Christian Gudrian 38 | Christian Kamm 39 | Chuck Remes 40 | Conrad D. Steenberg 41 | Constantin Rack 42 | Daniel J. Bernstein 43 | Dhammika Pathirana 44 | Dhruva Krishnamurthy 45 | Dirk O. Kaar 46 | Doron Somech 47 | Douglas Creager 48 | Drew Crawford 49 | Erich Heine 50 | Erik Hugne 51 | Erik Rigtorp 52 | Fabien Ninoles 53 | Frank Denis 54 | George Neill 55 | Gerard Toonstra 56 | Ghislain Putois 57 | Gonzalo Diethelm 58 | Guido Goldstein 59 | Harald Achitz 60 | Hardeep Singh 61 | Hiten Pandya 62 | Ian Barber 63 | Ilja Golshtein 64 | Ilya Kulakov 65 | Ivo Danihelka 66 | Jacob Rideout 67 | Joe Thornber 68 | Jon Dyte 69 | Kamil Shakirov 70 | Ken Steele 71 | Kouhei Sutou 72 | Laurent Alebarde 73 | Leonardo J. Consoni 74 | Lionel Flandrin 75 | Lourens Naudé 76 | Luca Boccassi 77 | Marc Rossi 78 | Mark Barbisan 79 | Martin Hurton 80 | Martin Lucina 81 | Martin Pales 82 | Martin Sustrik 83 | Matus Hamorsky 84 | Max Wolf 85 | McClain Looney 86 | Michael Compton 87 | Mika Fischer 88 | Mikael Helbo Kjaer 89 | Mike Gatny 90 | Mikko Koppanen 91 | Min Ragan-Kelley 92 | Neale Ferguson 93 | Nir Soffer 94 | Osiris Pedroso 95 | Paul Betts 96 | Paul Colomiets 97 | Pavel Gushcha 98 | Pavol Malosek 99 | Perry Kundert 100 | Peter Bourgon 101 | Philip Kovacs 102 | Pieter Hintjens 103 | Piotr Trojanek 104 | Reza Ebrahimi 105 | Richard Newton 106 | Rik van der Heijden 107 | Robert G. Jakabosky 108 | Sebastian Otaegui 109 | Stefan Radomski 110 | Steven McCoy 111 | Stuart Webster 112 | Tamara Kustarova 113 | Taras Shpot 114 | Tero Marttila 115 | Terry Wilson 116 | Thijs Terlouw 117 | Thomas Rodgers 118 | Tim Mossbarger 119 | Toralf Wittner 120 | Tore Halvorsen 121 | Trevor Bernard 122 | Vitaly Mayatskikh 123 | 124 | Credits 125 | ======= 126 | 127 | Aamir Mohammad 128 | Adrian von Bidder 129 | Aleksey Yeschenko 130 | Alessio Spadaro 131 | Alexander Majorov 132 | Anh Vu 133 | Bernd Schumacher 134 | Brian Granger 135 | Carsten Dinkelmann 136 | David Bahi 137 | Dirk Eddelbuettel 138 | Evgueny Khartchenko 139 | Frank Vanden Berghen 140 | Ian Barber 141 | John Apps 142 | Markus Fischer 143 | Matt Muggeridge 144 | Michael Santy 145 | Oleg Sevostyanov 146 | Paulo Henrique Silva 147 | Peter Busser 148 | Peter Lemenkov 149 | Robert Zhang 150 | Toralf Wittner 151 | Zed Shaw 152 | 153 | -------------------------------------------------------------------------------- /C/COPYING.LESSER: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | 167 | -------------------------------------------------------------------------------- 168 | 169 | SPECIAL EXCEPTION GRANTED BY COPYRIGHT HOLDERS 170 | 171 | As a special exception, copyright holders give you permission to link this 172 | library with independent modules to produce an executable, regardless of 173 | the license terms of these independent modules, and to copy and distribute 174 | the resulting executable under terms of your choice, provided that you also 175 | meet, for each linked independent module, the terms and conditions of 176 | the license of that module. An independent module is a module which is not 177 | derived from or based on this library. If you modify this library, you must 178 | extend this exception to your version of the library. 179 | 180 | Note: this exception relieves you of any obligations under sections 4 and 5 181 | of this license, and section 6 of the GNU General Public License. 182 | -------------------------------------------------------------------------------- /C/zmq.h: -------------------------------------------------------------------------------- 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 . 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 3 44 | #define ZMQ_VERSION_PATCH 2 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 57 | #endif 58 | #include 59 | #include 60 | #if defined _WIN32 61 | // Set target version to Windows Server 2008, Windows Vista or higher. 62 | // Windows XP (0x0501) is supported but without client & server socket types. 63 | #ifndef _WIN32_WINNT 64 | #define _WIN32_WINNT 0x0600 65 | #endif 66 | 67 | #ifdef __MINGW32__ 68 | // Require Windows XP or higher with MinGW for getaddrinfo(). 69 | #if (_WIN32_WINNT >= 0x0501) 70 | #else 71 | #error You need at least Windows XP target 72 | #endif 73 | #endif 74 | #include 75 | #endif 76 | 77 | /* Handle DSO symbol visibility */ 78 | #if defined _WIN32 79 | #if defined ZMQ_STATIC 80 | #define ZMQ_EXPORT 81 | #elif defined DLL_EXPORT 82 | #define ZMQ_EXPORT __declspec(dllexport) 83 | #else 84 | #define ZMQ_EXPORT __declspec(dllimport) 85 | #endif 86 | #else 87 | #if defined __SUNPRO_C || defined __SUNPRO_CC 88 | #define ZMQ_EXPORT __global 89 | #elif (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER 90 | #define ZMQ_EXPORT __attribute__ ((visibility ("default"))) 91 | #else 92 | #define ZMQ_EXPORT 93 | #endif 94 | #endif 95 | 96 | /* Define integer types needed for event interface */ 97 | #define ZMQ_DEFINED_STDINT 1 98 | #if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_OPENVMS 99 | #include 100 | #elif defined _MSC_VER && _MSC_VER < 1600 101 | #ifndef uint64_t 102 | typedef unsigned __int64 uint64_t; 103 | #endif 104 | #ifndef int32_t 105 | typedef __int32 int32_t; 106 | #endif 107 | #ifndef uint32_t 108 | typedef unsigned __int32 uint32_t; 109 | #endif 110 | #ifndef uint16_t 111 | typedef unsigned __int16 uint16_t; 112 | #endif 113 | #ifndef uint8_t 114 | typedef unsigned __int8 uint8_t; 115 | #endif 116 | #else 117 | #include 118 | #endif 119 | 120 | // 32-bit AIX's pollfd struct members are called reqevents and rtnevents so it 121 | // defines compatibility macros for them. Need to include that header first to 122 | // stop build failures since zmq_pollset_t defines them as events and revents. 123 | #ifdef ZMQ_HAVE_AIX 124 | #include 125 | #endif 126 | 127 | 128 | /******************************************************************************/ 129 | /* 0MQ errors. */ 130 | /******************************************************************************/ 131 | 132 | /* A number random enough not to collide with different errno ranges on */ 133 | /* different OSes. The assumption is that error_t is at least 32-bit type. */ 134 | #define ZMQ_HAUSNUMERO 156384712 135 | 136 | /* On Windows platform some of the standard POSIX errnos are not defined. */ 137 | #ifndef ENOTSUP 138 | #define ENOTSUP (ZMQ_HAUSNUMERO + 1) 139 | #endif 140 | #ifndef EPROTONOSUPPORT 141 | #define EPROTONOSUPPORT (ZMQ_HAUSNUMERO + 2) 142 | #endif 143 | #ifndef ENOBUFS 144 | #define ENOBUFS (ZMQ_HAUSNUMERO + 3) 145 | #endif 146 | #ifndef ENETDOWN 147 | #define ENETDOWN (ZMQ_HAUSNUMERO + 4) 148 | #endif 149 | #ifndef EADDRINUSE 150 | #define EADDRINUSE (ZMQ_HAUSNUMERO + 5) 151 | #endif 152 | #ifndef EADDRNOTAVAIL 153 | #define EADDRNOTAVAIL (ZMQ_HAUSNUMERO + 6) 154 | #endif 155 | #ifndef ECONNREFUSED 156 | #define ECONNREFUSED (ZMQ_HAUSNUMERO + 7) 157 | #endif 158 | #ifndef EINPROGRESS 159 | #define EINPROGRESS (ZMQ_HAUSNUMERO + 8) 160 | #endif 161 | #ifndef ENOTSOCK 162 | #define ENOTSOCK (ZMQ_HAUSNUMERO + 9) 163 | #endif 164 | #ifndef EMSGSIZE 165 | #define EMSGSIZE (ZMQ_HAUSNUMERO + 10) 166 | #endif 167 | #ifndef EAFNOSUPPORT 168 | #define EAFNOSUPPORT (ZMQ_HAUSNUMERO + 11) 169 | #endif 170 | #ifndef ENETUNREACH 171 | #define ENETUNREACH (ZMQ_HAUSNUMERO + 12) 172 | #endif 173 | #ifndef ECONNABORTED 174 | #define ECONNABORTED (ZMQ_HAUSNUMERO + 13) 175 | #endif 176 | #ifndef ECONNRESET 177 | #define ECONNRESET (ZMQ_HAUSNUMERO + 14) 178 | #endif 179 | #ifndef ENOTCONN 180 | #define ENOTCONN (ZMQ_HAUSNUMERO + 15) 181 | #endif 182 | #ifndef ETIMEDOUT 183 | #define ETIMEDOUT (ZMQ_HAUSNUMERO + 16) 184 | #endif 185 | #ifndef EHOSTUNREACH 186 | #define EHOSTUNREACH (ZMQ_HAUSNUMERO + 17) 187 | #endif 188 | #ifndef ENETRESET 189 | #define ENETRESET (ZMQ_HAUSNUMERO + 18) 190 | #endif 191 | 192 | /* Native 0MQ error codes. */ 193 | #define EFSM (ZMQ_HAUSNUMERO + 51) 194 | #define ENOCOMPATPROTO (ZMQ_HAUSNUMERO + 52) 195 | #define ETERM (ZMQ_HAUSNUMERO + 53) 196 | #define EMTHREAD (ZMQ_HAUSNUMERO + 54) 197 | 198 | /* This function retrieves the errno as it is known to 0MQ library. The goal */ 199 | /* of this function is to make the code 100% portable, including where 0MQ */ 200 | /* compiled with certain CRT library (on Windows) is linked to an */ 201 | /* application that uses different CRT library. */ 202 | ZMQ_EXPORT int zmq_errno (void); 203 | 204 | /* Resolves system errors and 0MQ errors to human-readable string. */ 205 | ZMQ_EXPORT const char *zmq_strerror (int errnum_); 206 | 207 | /* Run-time API version detection */ 208 | ZMQ_EXPORT void zmq_version (int *major_, int *minor_, int *patch_); 209 | 210 | /******************************************************************************/ 211 | /* 0MQ infrastructure (a.k.a. context) initialisation & termination. */ 212 | /******************************************************************************/ 213 | 214 | /* Context options */ 215 | #define ZMQ_IO_THREADS 1 216 | #define ZMQ_MAX_SOCKETS 2 217 | #define ZMQ_SOCKET_LIMIT 3 218 | #define ZMQ_THREAD_PRIORITY 3 219 | #define ZMQ_THREAD_SCHED_POLICY 4 220 | #define ZMQ_MAX_MSGSZ 5 221 | #define ZMQ_MSG_T_SIZE 6 222 | #define ZMQ_THREAD_AFFINITY_CPU_ADD 7 223 | #define ZMQ_THREAD_AFFINITY_CPU_REMOVE 8 224 | #define ZMQ_THREAD_NAME_PREFIX 9 225 | 226 | /* Default for new contexts */ 227 | #define ZMQ_IO_THREADS_DFLT 1 228 | #define ZMQ_MAX_SOCKETS_DFLT 1023 229 | #define ZMQ_THREAD_PRIORITY_DFLT -1 230 | #define ZMQ_THREAD_SCHED_POLICY_DFLT -1 231 | 232 | ZMQ_EXPORT void *zmq_ctx_new (void); 233 | ZMQ_EXPORT int zmq_ctx_term (void *context_); 234 | ZMQ_EXPORT int zmq_ctx_shutdown (void *context_); 235 | ZMQ_EXPORT int zmq_ctx_set (void *context_, int option_, int optval_); 236 | ZMQ_EXPORT int zmq_ctx_get (void *context_, int option_); 237 | 238 | /* Old (legacy) API */ 239 | ZMQ_EXPORT void *zmq_init (int io_threads_); 240 | ZMQ_EXPORT int zmq_term (void *context_); 241 | ZMQ_EXPORT int zmq_ctx_destroy (void *context_); 242 | 243 | 244 | /******************************************************************************/ 245 | /* 0MQ message definition. */ 246 | /******************************************************************************/ 247 | 248 | /* Some architectures, like sparc64 and some variants of aarch64, enforce pointer 249 | * alignment and raise sigbus on violations. Make sure applications allocate 250 | * zmq_msg_t on addresses aligned on a pointer-size boundary to avoid this issue. 251 | */ 252 | typedef struct zmq_msg_t 253 | { 254 | #if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_ARM64)) 255 | __declspec(align (8)) unsigned char _[64]; 256 | #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_ARM_ARMV7VE)) 257 | __declspec(align (4)) unsigned char _[64]; 258 | #elif defined(__GNUC__) || defined(__INTEL_COMPILER) \ 259 | || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x590) \ 260 | || (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x590) 261 | unsigned char _[64] __attribute__ ((aligned (sizeof (void *)))); 262 | #else 263 | unsigned char _[64]; 264 | #endif 265 | } zmq_msg_t; 266 | 267 | typedef void(zmq_free_fn) (void *data_, void *hint_); 268 | 269 | ZMQ_EXPORT int zmq_msg_init (zmq_msg_t *msg_); 270 | ZMQ_EXPORT int zmq_msg_init_size (zmq_msg_t *msg_, size_t size_); 271 | ZMQ_EXPORT int zmq_msg_init_data ( 272 | zmq_msg_t *msg_, void *data_, size_t size_, zmq_free_fn *ffn_, void *hint_); 273 | ZMQ_EXPORT int zmq_msg_send (zmq_msg_t *msg_, void *s_, int flags_); 274 | ZMQ_EXPORT int zmq_msg_recv (zmq_msg_t *msg_, void *s_, int flags_); 275 | ZMQ_EXPORT int zmq_msg_close (zmq_msg_t *msg_); 276 | ZMQ_EXPORT int zmq_msg_move (zmq_msg_t *dest_, zmq_msg_t *src_); 277 | ZMQ_EXPORT int zmq_msg_copy (zmq_msg_t *dest_, zmq_msg_t *src_); 278 | ZMQ_EXPORT void *zmq_msg_data (zmq_msg_t *msg_); 279 | ZMQ_EXPORT size_t zmq_msg_size (const zmq_msg_t *msg_); 280 | ZMQ_EXPORT int zmq_msg_more (const zmq_msg_t *msg_); 281 | ZMQ_EXPORT int zmq_msg_get (const zmq_msg_t *msg_, int property_); 282 | ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg_, int property_, int optval_); 283 | ZMQ_EXPORT const char *zmq_msg_gets (const zmq_msg_t *msg_, 284 | const char *property_); 285 | 286 | /******************************************************************************/ 287 | /* 0MQ socket definition. */ 288 | /******************************************************************************/ 289 | 290 | /* Socket types. */ 291 | #define ZMQ_PAIR 0 292 | #define ZMQ_PUB 1 293 | #define ZMQ_SUB 2 294 | #define ZMQ_REQ 3 295 | #define ZMQ_REP 4 296 | #define ZMQ_DEALER 5 297 | #define ZMQ_ROUTER 6 298 | #define ZMQ_PULL 7 299 | #define ZMQ_PUSH 8 300 | #define ZMQ_XPUB 9 301 | #define ZMQ_XSUB 10 302 | #define ZMQ_STREAM 11 303 | 304 | /* Deprecated aliases */ 305 | #define ZMQ_XREQ ZMQ_DEALER 306 | #define ZMQ_XREP ZMQ_ROUTER 307 | 308 | /* Socket options. */ 309 | #define ZMQ_AFFINITY 4 310 | #define ZMQ_ROUTING_ID 5 311 | #define ZMQ_SUBSCRIBE 6 312 | #define ZMQ_UNSUBSCRIBE 7 313 | #define ZMQ_RATE 8 314 | #define ZMQ_RECOVERY_IVL 9 315 | #define ZMQ_SNDBUF 11 316 | #define ZMQ_RCVBUF 12 317 | #define ZMQ_RCVMORE 13 318 | #define ZMQ_FD 14 319 | #define ZMQ_EVENTS 15 320 | #define ZMQ_TYPE 16 321 | #define ZMQ_LINGER 17 322 | #define ZMQ_RECONNECT_IVL 18 323 | #define ZMQ_BACKLOG 19 324 | #define ZMQ_RECONNECT_IVL_MAX 21 325 | #define ZMQ_MAXMSGSIZE 22 326 | #define ZMQ_SNDHWM 23 327 | #define ZMQ_RCVHWM 24 328 | #define ZMQ_MULTICAST_HOPS 25 329 | #define ZMQ_RCVTIMEO 27 330 | #define ZMQ_SNDTIMEO 28 331 | #define ZMQ_LAST_ENDPOINT 32 332 | #define ZMQ_ROUTER_MANDATORY 33 333 | #define ZMQ_TCP_KEEPALIVE 34 334 | #define ZMQ_TCP_KEEPALIVE_CNT 35 335 | #define ZMQ_TCP_KEEPALIVE_IDLE 36 336 | #define ZMQ_TCP_KEEPALIVE_INTVL 37 337 | #define ZMQ_IMMEDIATE 39 338 | #define ZMQ_XPUB_VERBOSE 40 339 | #define ZMQ_ROUTER_RAW 41 340 | #define ZMQ_IPV6 42 341 | #define ZMQ_MECHANISM 43 342 | #define ZMQ_PLAIN_SERVER 44 343 | #define ZMQ_PLAIN_USERNAME 45 344 | #define ZMQ_PLAIN_PASSWORD 46 345 | #define ZMQ_CURVE_SERVER 47 346 | #define ZMQ_CURVE_PUBLICKEY 48 347 | #define ZMQ_CURVE_SECRETKEY 49 348 | #define ZMQ_CURVE_SERVERKEY 50 349 | #define ZMQ_PROBE_ROUTER 51 350 | #define ZMQ_REQ_CORRELATE 52 351 | #define ZMQ_REQ_RELAXED 53 352 | #define ZMQ_CONFLATE 54 353 | #define ZMQ_ZAP_DOMAIN 55 354 | #define ZMQ_ROUTER_HANDOVER 56 355 | #define ZMQ_TOS 57 356 | #define ZMQ_CONNECT_ROUTING_ID 61 357 | #define ZMQ_GSSAPI_SERVER 62 358 | #define ZMQ_GSSAPI_PRINCIPAL 63 359 | #define ZMQ_GSSAPI_SERVICE_PRINCIPAL 64 360 | #define ZMQ_GSSAPI_PLAINTEXT 65 361 | #define ZMQ_HANDSHAKE_IVL 66 362 | #define ZMQ_SOCKS_PROXY 68 363 | #define ZMQ_XPUB_NODROP 69 364 | #define ZMQ_BLOCKY 70 365 | #define ZMQ_XPUB_MANUAL 71 366 | #define ZMQ_XPUB_WELCOME_MSG 72 367 | #define ZMQ_STREAM_NOTIFY 73 368 | #define ZMQ_INVERT_MATCHING 74 369 | #define ZMQ_HEARTBEAT_IVL 75 370 | #define ZMQ_HEARTBEAT_TTL 76 371 | #define ZMQ_HEARTBEAT_TIMEOUT 77 372 | #define ZMQ_XPUB_VERBOSER 78 373 | #define ZMQ_CONNECT_TIMEOUT 79 374 | #define ZMQ_TCP_MAXRT 80 375 | #define ZMQ_THREAD_SAFE 81 376 | #define ZMQ_MULTICAST_MAXTPDU 84 377 | #define ZMQ_VMCI_BUFFER_SIZE 85 378 | #define ZMQ_VMCI_BUFFER_MIN_SIZE 86 379 | #define ZMQ_VMCI_BUFFER_MAX_SIZE 87 380 | #define ZMQ_VMCI_CONNECT_TIMEOUT 88 381 | #define ZMQ_USE_FD 89 382 | #define ZMQ_GSSAPI_PRINCIPAL_NAMETYPE 90 383 | #define ZMQ_GSSAPI_SERVICE_PRINCIPAL_NAMETYPE 91 384 | #define ZMQ_BINDTODEVICE 92 385 | 386 | /* Message options */ 387 | #define ZMQ_MORE 1 388 | #define ZMQ_SHARED 3 389 | 390 | /* Send/recv options. */ 391 | #define ZMQ_DONTWAIT 1 392 | #define ZMQ_SNDMORE 2 393 | 394 | /* Security mechanisms */ 395 | #define ZMQ_NULL 0 396 | #define ZMQ_PLAIN 1 397 | #define ZMQ_CURVE 2 398 | #define ZMQ_GSSAPI 3 399 | 400 | /* RADIO-DISH protocol */ 401 | #define ZMQ_GROUP_MAX_LENGTH 15 402 | 403 | /* Deprecated options and aliases */ 404 | #define ZMQ_IDENTITY ZMQ_ROUTING_ID 405 | #define ZMQ_CONNECT_RID ZMQ_CONNECT_ROUTING_ID 406 | #define ZMQ_TCP_ACCEPT_FILTER 38 407 | #define ZMQ_IPC_FILTER_PID 58 408 | #define ZMQ_IPC_FILTER_UID 59 409 | #define ZMQ_IPC_FILTER_GID 60 410 | #define ZMQ_IPV4ONLY 31 411 | #define ZMQ_DELAY_ATTACH_ON_CONNECT ZMQ_IMMEDIATE 412 | #define ZMQ_NOBLOCK ZMQ_DONTWAIT 413 | #define ZMQ_FAIL_UNROUTABLE ZMQ_ROUTER_MANDATORY 414 | #define ZMQ_ROUTER_BEHAVIOR ZMQ_ROUTER_MANDATORY 415 | 416 | /* Deprecated Message options */ 417 | #define ZMQ_SRCFD 2 418 | 419 | /******************************************************************************/ 420 | /* GSSAPI definitions */ 421 | /******************************************************************************/ 422 | 423 | /* GSSAPI principal name types */ 424 | #define ZMQ_GSSAPI_NT_HOSTBASED 0 425 | #define ZMQ_GSSAPI_NT_USER_NAME 1 426 | #define ZMQ_GSSAPI_NT_KRB5_PRINCIPAL 2 427 | 428 | /******************************************************************************/ 429 | /* 0MQ socket events and monitoring */ 430 | /******************************************************************************/ 431 | 432 | /* Socket transport events (TCP, IPC and TIPC only) */ 433 | 434 | #define ZMQ_EVENT_CONNECTED 0x0001 435 | #define ZMQ_EVENT_CONNECT_DELAYED 0x0002 436 | #define ZMQ_EVENT_CONNECT_RETRIED 0x0004 437 | #define ZMQ_EVENT_LISTENING 0x0008 438 | #define ZMQ_EVENT_BIND_FAILED 0x0010 439 | #define ZMQ_EVENT_ACCEPTED 0x0020 440 | #define ZMQ_EVENT_ACCEPT_FAILED 0x0040 441 | #define ZMQ_EVENT_CLOSED 0x0080 442 | #define ZMQ_EVENT_CLOSE_FAILED 0x0100 443 | #define ZMQ_EVENT_DISCONNECTED 0x0200 444 | #define ZMQ_EVENT_MONITOR_STOPPED 0x0400 445 | #define ZMQ_EVENT_ALL 0xFFFF 446 | /* Unspecified system errors during handshake. Event value is an errno. */ 447 | #define ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL 0x0800 448 | /* Handshake complete successfully with successful authentication (if * 449 | * enabled). Event value is unused. */ 450 | #define ZMQ_EVENT_HANDSHAKE_SUCCEEDED 0x1000 451 | /* Protocol errors between ZMTP peers or between server and ZAP handler. * 452 | * Event value is one of ZMQ_PROTOCOL_ERROR_* */ 453 | #define ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL 0x2000 454 | /* Failed authentication requests. Event value is the numeric ZAP status * 455 | * code, i.e. 300, 400 or 500. */ 456 | #define ZMQ_EVENT_HANDSHAKE_FAILED_AUTH 0x4000 457 | #define ZMQ_PROTOCOL_ERROR_ZMTP_UNSPECIFIED 0x10000000 458 | #define ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND 0x10000001 459 | #define ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_SEQUENCE 0x10000002 460 | #define ZMQ_PROTOCOL_ERROR_ZMTP_KEY_EXCHANGE 0x10000003 461 | #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_UNSPECIFIED 0x10000011 462 | #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_MESSAGE 0x10000012 463 | #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO 0x10000013 464 | #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_INITIATE 0x10000014 465 | #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR 0x10000015 466 | #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_READY 0x10000016 467 | #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_WELCOME 0x10000017 468 | #define ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_METADATA 0x10000018 469 | // the following two may be due to erroneous configuration of a peer 470 | #define ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC 0x11000001 471 | #define ZMQ_PROTOCOL_ERROR_ZMTP_MECHANISM_MISMATCH 0x11000002 472 | #define ZMQ_PROTOCOL_ERROR_ZAP_UNSPECIFIED 0x20000000 473 | #define ZMQ_PROTOCOL_ERROR_ZAP_MALFORMED_REPLY 0x20000001 474 | #define ZMQ_PROTOCOL_ERROR_ZAP_BAD_REQUEST_ID 0x20000002 475 | #define ZMQ_PROTOCOL_ERROR_ZAP_BAD_VERSION 0x20000003 476 | #define ZMQ_PROTOCOL_ERROR_ZAP_INVALID_STATUS_CODE 0x20000004 477 | #define ZMQ_PROTOCOL_ERROR_ZAP_INVALID_METADATA 0x20000005 478 | 479 | ZMQ_EXPORT void *zmq_socket (void *, int type_); 480 | ZMQ_EXPORT int zmq_close (void *s_); 481 | ZMQ_EXPORT int 482 | zmq_setsockopt (void *s_, int option_, const void *optval_, size_t optvallen_); 483 | ZMQ_EXPORT int 484 | zmq_getsockopt (void *s_, int option_, void *optval_, size_t *optvallen_); 485 | ZMQ_EXPORT int zmq_bind (void *s_, const char *addr_); 486 | ZMQ_EXPORT int zmq_connect (void *s_, const char *addr_); 487 | ZMQ_EXPORT int zmq_unbind (void *s_, const char *addr_); 488 | ZMQ_EXPORT int zmq_disconnect (void *s_, const char *addr_); 489 | ZMQ_EXPORT int zmq_send (void *s_, const void *buf_, size_t len_, int flags_); 490 | ZMQ_EXPORT int 491 | zmq_send_const (void *s_, const void *buf_, size_t len_, int flags_); 492 | ZMQ_EXPORT int zmq_recv (void *s_, void *buf_, size_t len_, int flags_); 493 | ZMQ_EXPORT int zmq_socket_monitor (void *s_, const char *addr_, int events_); 494 | 495 | 496 | /******************************************************************************/ 497 | /* Deprecated I/O multiplexing. Prefer using zmq_poller API */ 498 | /******************************************************************************/ 499 | 500 | #define ZMQ_POLLIN 1 501 | #define ZMQ_POLLOUT 2 502 | #define ZMQ_POLLERR 4 503 | #define ZMQ_POLLPRI 8 504 | 505 | typedef struct zmq_pollitem_t 506 | { 507 | void *socket; 508 | #if defined _WIN32 509 | SOCKET fd; 510 | #else 511 | int fd; 512 | #endif 513 | short events; 514 | short revents; 515 | } zmq_pollitem_t; 516 | 517 | #define ZMQ_POLLITEMS_DFLT 16 518 | 519 | ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_); 520 | 521 | /******************************************************************************/ 522 | /* Message proxying */ 523 | /******************************************************************************/ 524 | 525 | ZMQ_EXPORT int zmq_proxy (void *frontend_, void *backend_, void *capture_); 526 | ZMQ_EXPORT int zmq_proxy_steerable (void *frontend_, 527 | void *backend_, 528 | void *capture_, 529 | void *control_); 530 | 531 | /******************************************************************************/ 532 | /* Probe library capabilities */ 533 | /******************************************************************************/ 534 | 535 | #define ZMQ_HAS_CAPABILITIES 1 536 | ZMQ_EXPORT int zmq_has (const char *capability_); 537 | 538 | /* Deprecated aliases */ 539 | #define ZMQ_STREAMER 1 540 | #define ZMQ_FORWARDER 2 541 | #define ZMQ_QUEUE 3 542 | 543 | /* Deprecated methods */ 544 | ZMQ_EXPORT int zmq_device (int type_, void *frontend_, void *backend_); 545 | ZMQ_EXPORT int zmq_sendmsg (void *s_, zmq_msg_t *msg_, int flags_); 546 | ZMQ_EXPORT int zmq_recvmsg (void *s_, zmq_msg_t *msg_, int flags_); 547 | struct iovec; 548 | ZMQ_EXPORT int 549 | zmq_sendiov (void *s_, struct iovec *iov_, size_t count_, int flags_); 550 | ZMQ_EXPORT int 551 | zmq_recviov (void *s_, struct iovec *iov_, size_t *count_, int flags_); 552 | 553 | /******************************************************************************/ 554 | /* Encryption functions */ 555 | /******************************************************************************/ 556 | 557 | /* Encode data with Z85 encoding. Returns encoded data */ 558 | ZMQ_EXPORT char * 559 | zmq_z85_encode (char *dest_, const uint8_t *data_, size_t size_); 560 | 561 | /* Decode data with Z85 encoding. Returns decoded data */ 562 | ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest_, const char *string_); 563 | 564 | /* Generate z85-encoded public and private keypair with tweetnacl/libsodium. */ 565 | /* Returns 0 on success. */ 566 | ZMQ_EXPORT int zmq_curve_keypair (char *z85_public_key_, char *z85_secret_key_); 567 | 568 | /* Derive the z85-encoded public key from the z85-encoded secret key. */ 569 | /* Returns 0 on success. */ 570 | ZMQ_EXPORT int zmq_curve_public (char *z85_public_key_, 571 | const char *z85_secret_key_); 572 | 573 | /******************************************************************************/ 574 | /* Atomic utility methods */ 575 | /******************************************************************************/ 576 | 577 | ZMQ_EXPORT void *zmq_atomic_counter_new (void); 578 | ZMQ_EXPORT void zmq_atomic_counter_set (void *counter_, int value_); 579 | ZMQ_EXPORT int zmq_atomic_counter_inc (void *counter_); 580 | ZMQ_EXPORT int zmq_atomic_counter_dec (void *counter_); 581 | ZMQ_EXPORT int zmq_atomic_counter_value (void *counter_); 582 | ZMQ_EXPORT void zmq_atomic_counter_destroy (void **counter_p_); 583 | 584 | /******************************************************************************/ 585 | /* Scheduling timers */ 586 | /******************************************************************************/ 587 | 588 | #define ZMQ_HAVE_TIMERS 589 | 590 | typedef void(zmq_timer_fn) (int timer_id, void *arg); 591 | 592 | ZMQ_EXPORT void *zmq_timers_new (void); 593 | ZMQ_EXPORT int zmq_timers_destroy (void **timers_p); 594 | ZMQ_EXPORT int 595 | zmq_timers_add (void *timers, size_t interval, zmq_timer_fn handler, void *arg); 596 | ZMQ_EXPORT int zmq_timers_cancel (void *timers, int timer_id); 597 | ZMQ_EXPORT int 598 | zmq_timers_set_interval (void *timers, int timer_id, size_t interval); 599 | ZMQ_EXPORT int zmq_timers_reset (void *timers, int timer_id); 600 | ZMQ_EXPORT long zmq_timers_timeout (void *timers); 601 | ZMQ_EXPORT int zmq_timers_execute (void *timers); 602 | 603 | 604 | /******************************************************************************/ 605 | /* These functions are not documented by man pages -- use at your own risk. */ 606 | /* If you need these to be part of the formal ZMQ API, then (a) write a man */ 607 | /* page, and (b) write a test case in tests. */ 608 | /******************************************************************************/ 609 | 610 | /* Helper functions are used by perf tests so that they don't have to care */ 611 | /* about minutiae of time-related functions on different OS platforms. */ 612 | 613 | /* Starts the stopwatch. Returns the handle to the watch. */ 614 | ZMQ_EXPORT void *zmq_stopwatch_start (void); 615 | 616 | /* Returns the number of microseconds elapsed since the stopwatch was */ 617 | /* started, but does not stop or deallocate the stopwatch. */ 618 | ZMQ_EXPORT unsigned long zmq_stopwatch_intermediate (void *watch_); 619 | 620 | /* Stops the stopwatch. Returns the number of microseconds elapsed since */ 621 | /* the stopwatch was started, and deallocates that watch. */ 622 | ZMQ_EXPORT unsigned long zmq_stopwatch_stop (void *watch_); 623 | 624 | /* Sleeps for specified number of seconds. */ 625 | ZMQ_EXPORT void zmq_sleep (int seconds_); 626 | 627 | typedef void(zmq_thread_fn) (void *); 628 | 629 | /* Start a thread. Returns a handle to the thread. */ 630 | ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn *func_, void *arg_); 631 | 632 | /* Wait for thread to complete then free up resources. */ 633 | ZMQ_EXPORT void zmq_threadclose (void *thread_); 634 | 635 | 636 | /******************************************************************************/ 637 | /* These functions are DRAFT and disabled in stable releases, and subject to */ 638 | /* change at ANY time until declared stable. */ 639 | /******************************************************************************/ 640 | 641 | #ifdef ZMQ_BUILD_DRAFT_API 642 | 643 | /* DRAFT Socket types. */ 644 | #define ZMQ_SERVER 12 645 | #define ZMQ_CLIENT 13 646 | #define ZMQ_RADIO 14 647 | #define ZMQ_DISH 15 648 | #define ZMQ_GATHER 16 649 | #define ZMQ_SCATTER 17 650 | #define ZMQ_DGRAM 18 651 | 652 | /* DRAFT Socket options. */ 653 | #define ZMQ_ZAP_ENFORCE_DOMAIN 93 654 | #define ZMQ_LOOPBACK_FASTPATH 94 655 | #define ZMQ_METADATA 95 656 | #define ZMQ_MULTICAST_LOOP 96 657 | #define ZMQ_ROUTER_NOTIFY 97 658 | #define ZMQ_XPUB_MANUAL_LAST_VALUE 98 659 | #define ZMQ_SOCKS_USERNAME 99 660 | #define ZMQ_SOCKS_PASSWORD 100 661 | #define ZMQ_IN_BATCH_SIZE 101 662 | #define ZMQ_OUT_BATCH_SIZE 102 663 | 664 | /* DRAFT Context options */ 665 | #define ZMQ_ZERO_COPY_RECV 10 666 | 667 | /* DRAFT Socket methods. */ 668 | ZMQ_EXPORT int zmq_join (void *s, const char *group); 669 | ZMQ_EXPORT int zmq_leave (void *s, const char *group); 670 | 671 | /* DRAFT Msg methods. */ 672 | ZMQ_EXPORT int zmq_msg_set_routing_id (zmq_msg_t *msg, uint32_t routing_id); 673 | ZMQ_EXPORT uint32_t zmq_msg_routing_id (zmq_msg_t *msg); 674 | ZMQ_EXPORT int zmq_msg_set_group (zmq_msg_t *msg, const char *group); 675 | ZMQ_EXPORT const char *zmq_msg_group (zmq_msg_t *msg); 676 | 677 | /* DRAFT Msg property names. */ 678 | #define ZMQ_MSG_PROPERTY_ROUTING_ID "Routing-Id" 679 | #define ZMQ_MSG_PROPERTY_SOCKET_TYPE "Socket-Type" 680 | #define ZMQ_MSG_PROPERTY_USER_ID "User-Id" 681 | #define ZMQ_MSG_PROPERTY_PEER_ADDRESS "Peer-Address" 682 | 683 | /* Router notify options */ 684 | #define ZMQ_NOTIFY_CONNECT 1 685 | #define ZMQ_NOTIFY_DISCONNECT 2 686 | 687 | /******************************************************************************/ 688 | /* Poller polling on sockets,fd and thread-safe sockets */ 689 | /******************************************************************************/ 690 | 691 | #define ZMQ_HAVE_POLLER 692 | 693 | #if defined _WIN32 694 | typedef SOCKET zmq_fd_t; 695 | #else 696 | typedef int zmq_fd_t; 697 | #endif 698 | 699 | typedef struct zmq_poller_event_t 700 | { 701 | void *socket; 702 | zmq_fd_t fd; 703 | void *user_data; 704 | short events; 705 | } zmq_poller_event_t; 706 | 707 | ZMQ_EXPORT void *zmq_poller_new (void); 708 | ZMQ_EXPORT int zmq_poller_destroy (void **poller_p); 709 | ZMQ_EXPORT int 710 | zmq_poller_add (void *poller, void *socket, void *user_data, short events); 711 | ZMQ_EXPORT int zmq_poller_modify (void *poller, void *socket, short events); 712 | ZMQ_EXPORT int zmq_poller_remove (void *poller, void *socket); 713 | ZMQ_EXPORT int 714 | zmq_poller_wait (void *poller, zmq_poller_event_t *event, long timeout); 715 | ZMQ_EXPORT int zmq_poller_wait_all (void *poller, 716 | zmq_poller_event_t *events, 717 | int n_events, 718 | long timeout); 719 | ZMQ_EXPORT int zmq_poller_fd (void *poller, zmq_fd_t *fd); 720 | 721 | ZMQ_EXPORT int 722 | zmq_poller_add_fd (void *poller, zmq_fd_t fd, void *user_data, short events); 723 | ZMQ_EXPORT int zmq_poller_modify_fd (void *poller, zmq_fd_t fd, short events); 724 | ZMQ_EXPORT int zmq_poller_remove_fd (void *poller, zmq_fd_t fd); 725 | 726 | ZMQ_EXPORT int zmq_socket_get_peer_state (void *socket, 727 | const void *routing_id, 728 | size_t routing_id_size); 729 | 730 | /* DRAFT Socket monitoring events */ 731 | #define ZMQ_EVENT_PIPES_STATS 0x10000 732 | 733 | #define ZMQ_CURRENT_EVENT_VERSION 1 734 | #define ZMQ_CURRENT_EVENT_VERSION_DRAFT 2 735 | 736 | #define ZMQ_EVENT_ALL_V1 ZMQ_EVENT_ALL 737 | #define ZMQ_EVENT_ALL_V2 ZMQ_EVENT_ALL_V1 | ZMQ_EVENT_PIPES_STATS 738 | 739 | ZMQ_EXPORT int zmq_socket_monitor_versioned ( 740 | void *s_, const char *addr_, uint64_t events_, int event_version_, int type_); 741 | ZMQ_EXPORT int zmq_socket_monitor_pipes_stats (void *s); 742 | 743 | #endif // ZMQ_BUILD_DRAFT_API 744 | 745 | 746 | #undef ZMQ_EXPORT 747 | 748 | #ifdef __cplusplus 749 | } 750 | #endif 751 | 752 | #endif 753 | -------------------------------------------------------------------------------- /C/zmq_utils.h: -------------------------------------------------------------------------------- 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 . 28 | */ 29 | 30 | /* This file is deprecated, and all its functionality provided by zmq.h */ 31 | /* Note that -Wpedantic compilation requires GCC to avoid using its custom 32 | extensions such as #warning, hence the trick below. Also, pragmas for 33 | warnings or other messages are not standard, not portable, and not all 34 | compilers even have an equivalent concept. 35 | So in the worst case, this include file is treated as silently empty. */ 36 | 37 | #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) \ 38 | || defined(_MSC_VER) 39 | #if defined(__GNUC__) || defined(__GNUG__) 40 | #pragma GCC diagnostic push 41 | #pragma GCC diagnostic warning "-Wcpp" 42 | #pragma GCC diagnostic ignored "-Werror" 43 | #pragma GCC diagnostic ignored "-Wall" 44 | #endif 45 | #pragma message( \ 46 | "Warning: zmq_utils.h is deprecated. All its functionality is provided by zmq.h.") 47 | #if defined(__GNUC__) || defined(__GNUG__) 48 | #pragma GCC diagnostic pop 49 | #endif 50 | #endif 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ZeroMQ bindings for the D programming language 2 | ============================================== 3 | This repository contains D bindings to the [ZeroMQ] C library (libzmq). 4 | It is part of [Deimos] and is maintained by the [Deimos team]. 5 | 6 | Like all Deimos bindings, these are just D prototypes for the C functions. 7 | For a higher-level D wrapper, see e.g. [zmqd] 8 | 9 | Usage 10 | ----- 11 | To use these bindings, simply add 12 | 13 | import deimos.zmq.zmq; 14 | 15 | to your D program and link it with the `zmq` library. 16 | 17 | Versioning 18 | ---------- 19 | Starting with v5.0.0, the version numbers of these bindings no longer 20 | correspond to upstream ZeroMQ versions. This allows us to follow the 21 | [Semantic Versioning] scheme and increment the version number when we 22 | make changes that do not correspond to upstream changes (e.g. to fix 23 | bugs in the bindings). 24 | 25 | The corresponding ZeroMQ version is indicated after the bindings version, 26 | following a plus sign. For example, the tag `v5.0.0+zmq-4-2-2` indicates 27 | bindings version 5.0.0, corresponding to ZeroMQ version 4.2.2. 28 | 29 | Up to and including v4.2.2, the bindings versions corresponded exactly to 30 | upstream ZeroMQ versions. 31 | 32 | Authors 33 | ------- 34 | These bindings were originally based on code by [itiu]. For the full 35 | list of contributors, see the [Contributors] page on GitHub. 36 | 37 | [ZeroMQ]: http://zeromq.org 38 | [Deimos]: https://github.com/D-Programming-Deimos 39 | [Deimos team]: https://github.com/orgs/D-Programming-Deimos/people 40 | [zmqd]: https://github.com/kyllingstad/zmqd 41 | [Semantic Versioning]: https://semver.org 42 | [itiu]: https://github.com/itiu 43 | [Contributors]: https://github.com/D-Programming-Deimos/ZeroMQ/graphs/contributors 44 | -------------------------------------------------------------------------------- /deimos/zmq/utils.d: -------------------------------------------------------------------------------- 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 . 28 | */ 29 | 30 | module deimos.zmq.utils; 31 | 32 | /* This file is deprecated, and all its functionality provided by zmq.h */ 33 | -------------------------------------------------------------------------------- /deimos/zmq/zmq.d: -------------------------------------------------------------------------------- 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 . 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 | module deimos.zmq.zmq; 38 | 39 | import core.stdc.config; 40 | 41 | nothrow extern (C) 42 | { 43 | 44 | /* Version macros for compile-time API version detection */ 45 | enum ZMQ_VERSION_MAJOR = 4; 46 | enum ZMQ_VERSION_MINOR = 3; 47 | enum ZMQ_VERSION_PATCH = 2; 48 | 49 | int ZMQ_MAKE_VERSION(int major, int minor, int patch) 50 | { 51 | return major * 10000 + minor * 100 + patch; 52 | } 53 | enum ZMQ_VERSION = 54 | ZMQ_MAKE_VERSION(ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH); 55 | 56 | /******************************************************************************/ 57 | /* 0MQ errors. */ 58 | /******************************************************************************/ 59 | 60 | /* A number random anough not to collide with different errno ranges on */ 61 | /* different OSes. The assumption is that error_t is at least 32-bit type. */ 62 | enum 63 | { 64 | ZMQ_HAUSNUMERO = 156384712, 65 | 66 | /* On Windows platform some of the standard POSIX errnos are not defined. */ 67 | ENOTSUP = (ZMQ_HAUSNUMERO + 1), 68 | EPROTONOSUPPORT = (ZMQ_HAUSNUMERO + 2), 69 | ENOBUFS = (ZMQ_HAUSNUMERO + 3), 70 | ENETDOWN = (ZMQ_HAUSNUMERO + 4), 71 | EADDRINUSE = (ZMQ_HAUSNUMERO + 5), 72 | EADDRNOTAVAIL = (ZMQ_HAUSNUMERO + 6), 73 | ECONNREFUSED = (ZMQ_HAUSNUMERO + 7), 74 | EINPROGRESS = (ZMQ_HAUSNUMERO + 8), 75 | ENOTSOCK = (ZMQ_HAUSNUMERO + 9), 76 | EMSGSIZE = (ZMQ_HAUSNUMERO + 10), 77 | EAFNOSUPPORT = (ZMQ_HAUSNUMERO + 11), 78 | ENETUNREACH = (ZMQ_HAUSNUMERO + 12), 79 | ECONNABORTED = (ZMQ_HAUSNUMERO + 13), 80 | ECONNRESET = (ZMQ_HAUSNUMERO + 14), 81 | ENOTCONN = (ZMQ_HAUSNUMERO + 15), 82 | ETIMEDOUT = (ZMQ_HAUSNUMERO + 16), 83 | EHOSTUNREACH = (ZMQ_HAUSNUMERO + 17), 84 | ENETRESET = (ZMQ_HAUSNUMERO + 18), 85 | 86 | /* Native 0MQ error codes. */ 87 | EFSM = (ZMQ_HAUSNUMERO + 51), 88 | ENOCOMPATPROTO = (ZMQ_HAUSNUMERO + 52), 89 | ETERM = (ZMQ_HAUSNUMERO + 53), 90 | EMTHREAD = (ZMQ_HAUSNUMERO + 54) 91 | }//enum error_code 92 | 93 | /* This function retrieves the errno as it is known to 0MQ library. The goal */ 94 | /* of this function is to make the code 100% portable, including where 0MQ */ 95 | /* compiled with certain CRT library (on Windows) is linked to an */ 96 | /* application that uses different CRT library. */ 97 | int zmq_errno(); 98 | 99 | /* Resolves system errors and 0MQ errors to human-readable string. */ 100 | const(char)* zmq_strerror(int errnum_); 101 | 102 | /* Run-time API version detection */ 103 | void zmq_version (int* major_, int* minor_, int* patch_); 104 | 105 | /******************************************************************************/ 106 | /* 0MQ infrastructure (a.k.a. context) initialisation & termination. */ 107 | /******************************************************************************/ 108 | 109 | /* Context options */ 110 | enum ZMQ_IO_THREADS = 1; 111 | enum ZMQ_MAX_SOCKETS = 2; 112 | enum ZMQ_SOCKET_LIMIT = 3; 113 | enum ZMQ_THREAD_PRIORITY = 3; 114 | enum ZMQ_THREAD_SCHED_POLICY = 4; 115 | enum ZMQ_MAX_MSGSZ = 5; 116 | enum ZMQ_MSG_T_SIZE = 6; 117 | enum ZMQ_THREAD_AFFINITY_CPU_ADD = 7; 118 | enum ZMQ_THREAD_AFFINITY_CPU_REMOVE = 8; 119 | enum ZMQ_THREAD_NAME_PREFIX = 9; 120 | 121 | /* Default for new contexts */ 122 | enum 123 | { 124 | ZMQ_IO_THREADS_DFLT = 1, 125 | ZMQ_MAX_SOCKETS_DFLT = 1023, 126 | ZMQ_THREAD_PRIORITY_DFLT = -1, 127 | ZMQ_THREAD_SCHED_POLICY_DFLT = -1, 128 | } 129 | 130 | void* zmq_ctx_new(); 131 | int zmq_ctx_term(void* context_); 132 | int zmq_ctx_shutdown(void* context_); 133 | int zmq_ctx_set(void* context_, int option_, int optval_); 134 | int zmq_ctx_get(void* context_, int option_); 135 | 136 | /* Old (legacy) API */ 137 | void* zmq_init(int io_threads_); 138 | int zmq_term(void* context_); 139 | int zmq_ctx_destroy(void* context_); 140 | 141 | 142 | /******************************************************************************/ 143 | /* 0MQ message definition. */ 144 | /******************************************************************************/ 145 | 146 | /* Some architectures, like sparc64 and some variance of aarch64, enforce pointer 147 | * alignment and raise sigbus on violations. Make sure applications allocate 148 | * zmq_msg_t on addresses aligned on a pointer-size-boundary to avoid this issue. 149 | */ 150 | struct zmq_msg_t 151 | { 152 | align((void*).sizeof) ubyte[64] _; 153 | } 154 | 155 | int zmq_msg_init(zmq_msg_t* msg_); 156 | int zmq_msg_init_size(zmq_msg_t* msg_, size_t size_); 157 | int zmq_msg_init_data( 158 | zmq_msg_t* msg_, void* data_, size_t size_, void function(void* data_, void* hint_) nothrow ffn_, void* hint_); 159 | int zmq_msg_send(zmq_msg_t* msg_, void* s_, int flags_); 160 | int zmq_msg_recv(zmq_msg_t* msg_, void* s_, int flags_); 161 | int zmq_msg_close(zmq_msg_t* msg_); 162 | int zmq_msg_move(zmq_msg_t* dest_, zmq_msg_t* src_); 163 | int zmq_msg_copy(zmq_msg_t* dest_, zmq_msg_t* src_); 164 | void* zmq_msg_data(zmq_msg_t* msg_); 165 | size_t zmq_msg_size(const(zmq_msg_t)* msg_); 166 | int zmq_msg_more(const(zmq_msg_t)* msg_); 167 | int zmq_msg_get(const(zmq_msg_t)* msg_, int property_); 168 | int zmq_msg_set(zmq_msg_t* msg_, int property_, int optval_); 169 | const(char)* zmq_msg_gets(const(zmq_msg_t)* msg_, 170 | const(char)* property_); 171 | 172 | /******************************************************************************/ 173 | /* 0MQ socket definition. */ 174 | /******************************************************************************/ 175 | 176 | /* Socket types. */ 177 | enum 178 | { 179 | ZMQ_PAIR = 0, 180 | ZMQ_PUB = 1, 181 | ZMQ_SUB = 2, 182 | ZMQ_REQ = 3, 183 | ZMQ_REP = 4, 184 | ZMQ_DEALER = 5, 185 | ZMQ_ROUTER = 6, 186 | ZMQ_PULL = 7, 187 | ZMQ_PUSH = 8, 188 | ZMQ_XPUB = 9, 189 | ZMQ_XSUB = 10, 190 | ZMQ_STREAM = 11, 191 | } 192 | 193 | /* Deprecated aliases */ 194 | enum 195 | { 196 | ZMQ_XREQ = ZMQ_DEALER, 197 | ZMQ_XREP = ZMQ_ROUTER, 198 | } 199 | 200 | /* Socket options. */ 201 | enum ZMQ_AFFINITY = 4; 202 | enum ZMQ_ROUTING_ID = 5; 203 | enum ZMQ_SUBSCRIBE = 6; 204 | enum ZMQ_UNSUBSCRIBE = 7; 205 | enum ZMQ_RATE = 8; 206 | enum ZMQ_RECOVERY_IVL = 9; 207 | enum ZMQ_SNDBUF = 11; 208 | enum ZMQ_RCVBUF = 12; 209 | enum ZMQ_RCVMORE = 13; 210 | enum ZMQ_FD = 14; 211 | enum ZMQ_EVENTS = 15; 212 | enum ZMQ_TYPE = 16; 213 | enum ZMQ_LINGER = 17; 214 | enum ZMQ_RECONNECT_IVL = 18; 215 | enum ZMQ_BACKLOG = 19; 216 | enum ZMQ_RECONNECT_IVL_MAX = 21; 217 | enum ZMQ_MAXMSGSIZE = 22; 218 | enum ZMQ_SNDHWM = 23; 219 | enum ZMQ_RCVHWM = 24; 220 | enum ZMQ_MULTICAST_HOPS = 25; 221 | enum ZMQ_RCVTIMEO = 27; 222 | enum ZMQ_SNDTIMEO = 28; 223 | enum ZMQ_LAST_ENDPOINT = 32; 224 | enum ZMQ_ROUTER_MANDATORY = 33; 225 | enum ZMQ_TCP_KEEPALIVE = 34; 226 | enum ZMQ_TCP_KEEPALIVE_CNT = 35; 227 | enum ZMQ_TCP_KEEPALIVE_IDLE = 36; 228 | enum ZMQ_TCP_KEEPALIVE_INTVL = 37; 229 | enum ZMQ_IMMEDIATE = 39; 230 | enum ZMQ_XPUB_VERBOSE = 40; 231 | enum ZMQ_ROUTER_RAW = 41; 232 | enum ZMQ_IPV6 = 42; 233 | enum ZMQ_MECHANISM = 43; 234 | enum ZMQ_PLAIN_SERVER = 44; 235 | enum ZMQ_PLAIN_USERNAME = 45; 236 | enum ZMQ_PLAIN_PASSWORD = 46; 237 | enum ZMQ_CURVE_SERVER = 47; 238 | enum ZMQ_CURVE_PUBLICKEY = 48; 239 | enum ZMQ_CURVE_SECRETKEY = 49; 240 | enum ZMQ_CURVE_SERVERKEY = 50; 241 | enum ZMQ_PROBE_ROUTER = 51; 242 | enum ZMQ_REQ_CORRELATE = 52; 243 | enum ZMQ_REQ_RELAXED = 53; 244 | enum ZMQ_CONFLATE = 54; 245 | enum ZMQ_ZAP_DOMAIN = 55; 246 | enum ZMQ_ROUTER_HANDOVER = 56; 247 | enum ZMQ_TOS = 57; 248 | enum ZMQ_CONNECT_ROUTING_ID = 61; 249 | enum ZMQ_GSSAPI_SERVER = 62; 250 | enum ZMQ_GSSAPI_PRINCIPAL = 63; 251 | enum ZMQ_GSSAPI_SERVICE_PRINCIPAL= 64; 252 | enum ZMQ_GSSAPI_PLAINTEXT = 65; 253 | enum ZMQ_HANDSHAKE_IVL = 66; 254 | enum ZMQ_SOCKS_PROXY = 68; 255 | enum ZMQ_XPUB_NODROP = 69; 256 | enum ZMQ_BLOCKY = 70; 257 | enum ZMQ_XPUB_MANUAL = 71; 258 | enum ZMQ_XPUB_WELCOME_MSG = 72; 259 | enum ZMQ_STREAM_NOTIFY = 73; 260 | enum ZMQ_INVERT_MATCHING = 74; 261 | enum ZMQ_HEARTBEAT_IVL = 75; 262 | enum ZMQ_HEARTBEAT_TTL = 76; 263 | enum ZMQ_HEARTBEAT_TIMEOUT = 77; 264 | enum ZMQ_XPUB_VERBOSER = 78; 265 | enum ZMQ_CONNECT_TIMOUT = 79; 266 | enum ZMQ_TCP_MAXRT = 80; 267 | enum ZMQ_THREAD_SAFE = 81; 268 | enum ZMQ_MULTICAST_MAXTPDU = 84; 269 | enum ZMQ_VMCI_BUFFER_SIZE = 85; 270 | enum ZMQ_VMCI_BUFFER_MIN_SIZE = 86; 271 | enum ZMQ_VMCI_BUFFER_MAX_SIZE = 87; 272 | enum ZMQ_VMCI_CONNECT_TIMEOUT = 88; 273 | enum ZMQ_USE_FD = 89; 274 | enum ZMQ_GSSAPI_PRINCIPAL_NAMETYPE = 90; 275 | enum ZMQ_GSSAPI_SERVICE_PRINCIPAL_NAMETYPE = 91; 276 | enum ZMQ_BINDTODEVICE = 92; 277 | 278 | 279 | /* Message options */ 280 | enum 281 | { 282 | ZMQ_MORE = 1, 283 | ZMQ_SHARED = 3, 284 | } 285 | 286 | /* Send/recv options. */ 287 | enum 288 | { 289 | ZMQ_DONTWAIT = 1, 290 | ZMQ_SNDMORE = 2 291 | } 292 | 293 | /* Security mechanisms */ 294 | enum 295 | { 296 | ZMQ_NULL = 0, 297 | ZMQ_PLAIN = 1, 298 | ZMQ_CURVE = 2, 299 | ZMQ_GSSAPI = 3, 300 | } 301 | 302 | /* RADIO_DISH protocol */ 303 | enum ZMQ_GROUP_MAX_LENGTH = 15; 304 | 305 | /* Deprecated options and aliases */ 306 | enum ZMQ_IDENTITY = ZMQ_ROUTING_ID; 307 | enum ZMQ_CONNECT_RID = ZMQ_CONNECT_ROUTING_ID; 308 | enum ZMQ_TCP_ACCEPT_FILTER = 38; 309 | enum ZMQ_IPC_FILTER_PID = 58; 310 | enum ZMQ_IPC_FILTER_UID = 59; 311 | enum ZMQ_IPC_FILTER_GID = 60; 312 | enum ZMQ_IPV4ONLY = 31; 313 | enum ZMQ_DELAY_ATTACH_ON_CONNECT = ZMQ_IMMEDIATE; 314 | enum ZMQ_NOBLOCK = ZMQ_DONTWAIT; 315 | enum ZMQ_FAIL_UNROUTABLE = ZMQ_ROUTER_MANDATORY; 316 | enum ZMQ_ROUTER_BEHAVIOR = ZMQ_ROUTER_MANDATORY; 317 | 318 | /* Deprecated Message options */ 319 | enum ZMQ_SRCFD = 2; 320 | 321 | /******************************************************************************/ 322 | /* GSSAPI definitions */ 323 | /******************************************************************************/ 324 | 325 | /* GSSAPI principal name types */ 326 | enum ZMQ_GSSAPI_NT_HOSTBASED = 0; 327 | enum ZMQ_GSSAPI_NT_USER_NAME = 1; 328 | enum ZMQ_GSSAPI_NT_KRB5_PRINCIPAL = 2; 329 | 330 | /******************************************************************************/ 331 | /* 0MQ socket events and monitoring */ 332 | /******************************************************************************/ 333 | 334 | /* Socket transport events (TCP, IPC, and TIPC only) */ 335 | 336 | enum ZMQ_EVENT_CONNECTED = 0x0001; 337 | enum ZMQ_EVENT_CONNECT_DELAYED = 0x0002; 338 | enum ZMQ_EVENT_CONNECT_RETRIED = 0x0004; 339 | enum ZMQ_EVENT_LISTENING = 0x0008; 340 | enum ZMQ_EVENT_BIND_FAILED = 0x0010; 341 | enum ZMQ_EVENT_ACCEPTED = 0x0020; 342 | enum ZMQ_EVENT_ACCEPT_FAILED = 0x0040; 343 | enum ZMQ_EVENT_CLOSED = 0x0080; 344 | enum ZMQ_EVENT_CLOSE_FAILED = 0x0100; 345 | enum ZMQ_EVENT_DISCONNECTED = 0x0200; 346 | enum ZMQ_EVENT_MONITOR_STOPPED = 0x0400; 347 | enum ZMQ_EVENT_ALL = 0xFFFF; 348 | /* Unspecified system errors during handshake. Event value is an errno. */ 349 | enum ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL = 0x0800; 350 | /* Handshake complete successfully with successful authentication (if * 351 | * enabled). Event value is unused. */ 352 | enum ZMQ_EVENT_HANDSHAKE_SUCCEEDED = 0x1000; 353 | /* Protocol errors between ZMTP peers or between server and ZAP handler. * 354 | * Event value is one of ZMQ_PROTOCOL_ERROR_* */ 355 | enum ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL = 0x2000; 356 | /* Failed authentication requests. Event value is the numeric ZAP status * 357 | * code, i.e. 300, 400 or 500. */ 358 | enum ZMQ_EVENT_HANDSHAKE_FAILED_AUTH = 0x4000; 359 | enum ZMQ_PROTOCOL_ERROR_ZMTP_UNSPECIFIED = 0x10000000; 360 | enum ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND = 0x10000001; 361 | enum ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_SEQUENCE = 0x10000002; 362 | enum ZMQ_PROTOCOL_ERROR_ZMTP_KEY_EXCHANGE = 0x10000003; 363 | enum ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_UNSPECIFIED = 0x10000011; 364 | enum ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_MESSAGE = 0x10000012; 365 | enum ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO = 0x10000013; 366 | enum ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_INITIATE = 0x10000014; 367 | enum ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR = 0x10000015; 368 | enum ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_READY = 0x10000016; 369 | enum ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_WELCOME = 0x10000017; 370 | enum ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_METADATA = 0x10000018; 371 | // the following two may be due to erroneous configuration of a peer 372 | enum ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC = 0x11000001; 373 | enum ZMQ_PROTOCOL_ERROR_ZMTP_MECHANISM_MISMATCH = 0x11000002; 374 | enum ZMQ_PROTOCOL_ERROR_ZAP_UNSPECIFIED = 0x20000000; 375 | enum ZMQ_PROTOCOL_ERROR_ZAP_MALFORMED_REPLY = 0x20000001; 376 | enum ZMQ_PROTOCOL_ERROR_ZAP_BAD_REQUEST_ID = 0x20000002; 377 | enum ZMQ_PROTOCOL_ERROR_ZAP_BAD_VERSION = 0x20000003; 378 | enum ZMQ_PROTOCOL_ERROR_ZAP_INVALID_STATUS_CODE = 0x20000004; 379 | enum ZMQ_PROTOCOL_ERROR_ZAP_INVALID_METADATA = 0x20000005; 380 | 381 | void* zmq_socket(void*, int type_); 382 | int zmq_close(void* s_); 383 | int zmq_setsockopt(void* s_, int option_, const void* optval_, size_t optvallen_); 384 | int zmq_getsockopt(void* s_, int option_, void* optval_, size_t *optvallen_); 385 | int zmq_bind(void* s_, const char* addr_); 386 | int zmq_connect(void* s_, const char* addr_); 387 | int zmq_unbind(void* s_, const char* addr_); 388 | int zmq_disconnect(void* s_, const char* addr_); 389 | int zmq_send(void* s_, const void* buf_, size_t len_, int flags_); 390 | int zmq_send_const(void *s_, const void* buf_, size_t len_, int flags_); 391 | int zmq_recv(void* s_, void* buf_, size_t len_, int flags_); 392 | int zmq_socket_monitor(void* s_, const char* addr_, int events_); 393 | 394 | 395 | /******************************************************************************/ 396 | /* Deprecated I/O multiplexing. Prefer using zmq_poller API */ 397 | /******************************************************************************/ 398 | 399 | enum 400 | { 401 | ZMQ_POLLIN = 1, 402 | ZMQ_POLLOUT = 2, 403 | ZMQ_POLLERR = 4, 404 | ZMQ_POLLPRI = 8, 405 | } 406 | 407 | struct zmq_pollitem_t 408 | { 409 | void* socket; 410 | version (Windows) 411 | { 412 | import core.sys.windows.winsock2: SOCKET; 413 | SOCKET fd; 414 | } 415 | else 416 | { 417 | int fd; 418 | } 419 | short events; 420 | short revents; 421 | } 422 | 423 | enum ZMQ_POLLITEMS_DFLT = 16; 424 | 425 | int zmq_poll(zmq_pollitem_t* items_, int nitems_, c_long timeout_); 426 | 427 | /******************************************************************************/ 428 | /* Message proxying */ 429 | /******************************************************************************/ 430 | 431 | int zmq_proxy(void* frontend_, void* backend_, void* capture_); 432 | int zmq_proxy_steerable(void* frontend_, 433 | void* backend_, 434 | void* capture_, 435 | void* control_); 436 | 437 | /******************************************************************************/ 438 | /* Probe library capabilities */ 439 | /******************************************************************************/ 440 | 441 | enum ZMQ_HAS_CAPABILITIES = 1; 442 | int zmq_has(const(char)* capability_); 443 | 444 | /* Deprecated aliases */ 445 | enum 446 | { 447 | ZMQ_STREAMER = 1, 448 | ZMQ_FORWARDER = 2, 449 | ZMQ_QUEUE = 3 450 | } 451 | 452 | /* Deprecated methods */ 453 | int zmq_device(int type_, void* frontend_, void* backend_); 454 | int zmq_sendmsg(void* s_, zmq_msg_t* msg_, int flags_); 455 | int zmq_recvmsg(void* s_, zmq_msg_t* msg_, int flags_); 456 | struct iovec; 457 | int zmq_sendiov(void* s_, iovec* iov_, size_t count_, int flags_); 458 | int zmq_recviov(void* s_, iovec* iov_, size_t* count_, int flags_); 459 | 460 | /******************************************************************************/ 461 | /* Encryption functions */ 462 | /******************************************************************************/ 463 | 464 | /* Encode data with Z85 encoding. Returns encoded data */ 465 | char* zmq_z85_encode(char* dest_, const(ubyte)* data_, size_t size_); 466 | 467 | /* Decode data with Z85 encoding. Returns decoded data */ 468 | ubyte* zmq_z85_decode(ubyte* dest_, const(char)* string_); 469 | 470 | /* Generate z85-encoded public and private keypair with tweetnacl/libsodium. */ 471 | /* Returns 0 on success. */ 472 | int zmq_curve_keypair(char* z85_public_key_, char* z85_secret_key_); 473 | 474 | /* Derive the z85-encoded public key from the z85-encoded secret key. */ 475 | /* Returns 0 on success. */ 476 | int zmq_curve_public(char* z85_public_key_, 477 | const(char)* z85_secret_key_); 478 | 479 | /******************************************************************************/ 480 | /* Atomic utility methods */ 481 | /******************************************************************************/ 482 | void* zmq_atomic_counter_new(); 483 | void zmq_atomic_counter_set(void* counter_, int value_); 484 | int zmq_atomic_counter_inc(void* counter_); 485 | int zmq_atomic_counter_dec(void* counter_); 486 | int zmq_atomic_counter_value(void* counter_); 487 | void zmq_atomic_counter_destroy(void** counter_p_); 488 | 489 | /******************************************************************************/ 490 | /* Scheduling timers */ 491 | /******************************************************************************/ 492 | 493 | enum ZMQ_HAVE_TIMERS = true; 494 | 495 | alias zmq_timer_fn = void function(int timer_id, void* arg); 496 | 497 | void* zmq_timers_new(); 498 | int zmq_timers_destroy(void** timers_p); 499 | int zmq_timers_add(void* timers, size_t interval, zmq_timer_fn handler, void* arg); 500 | int zmq_timers_cancel(void* timers, int timer_id); 501 | int zmq_timers_set_interval(void* timers, int timer_id, size_t interval); 502 | int zmq_timers_reset(void* timers, int timer_id); 503 | c_long zmq_timers_timeout(void* timers); 504 | int zmq_timers_execute(void* timers); 505 | 506 | 507 | /******************************************************************************/ 508 | /* These functions are not documented by man pages -- use at your own risk. */ 509 | /* If you need these to be part of the formal ZMQ API, then (a) write a man */ 510 | /* page, and (b) write a test case in tests. */ 511 | /******************************************************************************/ 512 | 513 | /* Helper functions are used by perf tests so that they don't have to care */ 514 | /* about minutiae of time-related functions on different OS platforms. */ 515 | 516 | /* Starts the stopwatch. Returns the handle to the watch. */ 517 | void* zmq_stopwatch_start(); 518 | 519 | /* Returns the number of microseconds elapsed since the stopwatch was */ 520 | /* started, but does not stop or deallocate the stopwatch. */ 521 | c_ulong zmq_stopwatch_intermediate(void* watch_); 522 | 523 | /* Stops the stopwatch. Returns the number of microseconds elapsed since */ 524 | /* the stopwatch was started, and deallocates that watch. */ 525 | c_ulong zmq_stopwatch_stop(void* watch_); 526 | 527 | /* Sleeps for specified number of seconds. */ 528 | void zmq_sleep(int seconds_); 529 | 530 | /* Start a thread. Returns a handle to the thread. */ 531 | void* zmq_threadstart(void function(void*) nothrow func_, void* arg_); 532 | 533 | /* Wait for thread to complete then free up resources. */ 534 | void zmq_threadclose(void* thread_); 535 | 536 | 537 | /******************************************************************************/ 538 | /* These functions are DRAFT and disabled in stable releases, and subject to */ 539 | /* change at ANY time until declared stable. */ 540 | /******************************************************************************/ 541 | version(ZMQ_BUILD_DRAFT_API) 542 | { 543 | /* DRAFT Socket types. */ 544 | enum 545 | { 546 | ZMQ_SERVER = 12, 547 | ZMQ_CLIENT = 13, 548 | ZMQ_RADIO = 14, 549 | ZMQ_DISH = 15, 550 | ZMQ_GATHER = 16, 551 | ZMQ_SCATTER = 17, 552 | ZMQ_DGRAM = 18, 553 | } 554 | 555 | /* DRAFT Socket options. */ 556 | enum ZMQ_ZAP_ENFORCE_DOMAIN = 93; 557 | enum ZMQ_LOOPBACK_FASTPATH = 94; 558 | enum ZMQ_METADATA = 95; 559 | enum ZMQ_MULTICAST_LOOP = 96; 560 | enum ZMQ_ROUTER_NOTIFY = 97; 561 | enum ZMQ_XPUB_MANUAL_LAST_VALUE = 98; 562 | enum ZMQ_SOCKS_USERNAME = 99; 563 | enum ZMQ_SOCKS_PASSWORD = 100; 564 | enum ZMQ_IN_BATCH_SIZE = 101; 565 | enum ZMQ_OUT_BATCH_SIZE = 102; 566 | 567 | /* DRAFT Context options */ 568 | enum ZMQ_ZERO_COPY_RECV = 10; 569 | 570 | /* DRAFT Socket methods. */ 571 | int zmq_join(void* s, const(char)* group); 572 | int zmq_leave(void* s, const(char)* group); 573 | 574 | /* DRAFT Msg methods. */ 575 | int zmq_msg_set_routing_id(zmq_msg_t* msg, uint routing_id); 576 | uint zmq_msg_routing_id(zmq_msg_t* msg); 577 | int zmq_msg_set_group(zmq_msg_t* msg, const(char)* group); 578 | const(char)* zmq_msg_group(zmq_msg_t* msg); 579 | 580 | /* DRAFT Msg property names. */ 581 | enum ZMQ_MSG_PROPERTY_ROUTING_ID = "Routing-Id"; 582 | enum ZMQ_MSG_PROPERTY_SOCKET_TYPE = "Socket-Type"; 583 | enum ZMQ_MSG_PROPERTY_USER_ID = "User-Id"; 584 | enum ZMQ_MSG_PROPERTY_PEER_ADDRESS = "Peer-Address"; 585 | 586 | /* Router notify options */ 587 | enum ZMQ_NOTIFY_CONNECT = 1; 588 | enum ZMQ_NOTIFY_DISCONNECT = 2; 589 | 590 | /******************************************************************************/ 591 | /* Poller polling on sockets,fd, and thread-safe sockets */ 592 | /******************************************************************************/ 593 | 594 | version(Windows) 595 | { 596 | alias zmq_fd_t = SOCKET; 597 | } 598 | else 599 | { 600 | alias zmq_fd_t = int; 601 | } 602 | 603 | struct zmq_poller_event_t 604 | { 605 | void* socket; 606 | zmq_fd_t fd; 607 | void* user_data; 608 | short events; 609 | } 610 | 611 | void* zmq_poller_new(); 612 | int zmq_poller_destroy(void** poller_p); 613 | int zmq_poller_add(void* poller, void* socket, void* user_data, short events); 614 | int zmq_poller_modify(void* poller, void* socket, short events); 615 | int zmq_poller_remove(void* poller, void* socket); 616 | int zmq_poller_wait(void* poller, zmq_poller_event_t* event, c_long timeout); 617 | int zmq_poller_wait_all(void* poller, 618 | zmq_poller_event_t* events, 619 | int n_events, 620 | c_long timout); 621 | int zmq_poller_fd(void* poller, zmq_fd_t* fd); 622 | 623 | int zmq_poller_add_fd(void* poller, zmq_fd_t fd, void* user_data, short events); 624 | int zmq_poller_modify_fd(void* poller, zmq_fd_t fd, short events); 625 | int zmq_poller_remove_fd(void* poller, zmq_fd_t fd); 626 | 627 | int zmq_socket_get_peer_state(void* socket, 628 | const(void)* routing_id, 629 | size_t routing_id_size); 630 | 631 | /* DRAFT Socket monitoring events */ 632 | enum ZMQ_EVENT_PIPES_STATS = 0x10000; 633 | 634 | enum ZMQ_CURRENT_EVENT_VERSION = 1; 635 | enum ZMQ_CURRENT_EVENT_VERSION_DRAFT = 2; 636 | 637 | enum ZMQ_EVENT_ALL_V1 = ZMQ_EVENT_ALL; 638 | enum ZMQ_EVENT_ALL_V2 = ZMQ_EVENT_ALL_V1 | ZMQ_EVENT_PIPES_STATS; 639 | 640 | int zmq_socket_monitor_versioned( 641 | void* s_, const(char)* addr_, ulong events_, int event_version_, int type_); 642 | int zmq_socket_monitor_pipes_stats(void* s); 643 | 644 | } // version(ZMQ_BUILD_DRAFT_API) 645 | 646 | }// extern (C) 647 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zeromq", 3 | "description": "Interface to the C ZeroMQ library", 4 | "homepage": "http://github.com/D-Programming-Deimos/ZeroMQ", 5 | "authors": [ 6 | "itiu", 7 | "Jude \"1100110\" Young", 8 | "Lars T. Kyllingstad" 9 | ], 10 | "license": "LGPL v3", 11 | "importPaths": [ 12 | "." 13 | ], 14 | "sourcePaths": [ 15 | "deimos" 16 | ], 17 | "libs": [ 18 | "zmq" 19 | ] 20 | } 21 | --------------------------------------------------------------------------------