Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-05-18 08:30:31

0001 /* SPDX-License-Identifier: MPL-2.0 */
0002 /*  *************************************************************************
0003     NOTE to contributors. This file comprises the principal public contract
0004     for ZeroMQ API users. Any change to this file supplied in a stable
0005     release SHOULD not break existing applications.
0006     In practice this means that the value of constants must not change, and
0007     that old values may not be reused for new constants.
0008     *************************************************************************
0009 */
0010 
0011 #ifndef __ZMQ_H_INCLUDED__
0012 #define __ZMQ_H_INCLUDED__
0013 
0014 /*  Version macros for compile-time API version detection                     */
0015 #define ZMQ_VERSION_MAJOR 4
0016 #define ZMQ_VERSION_MINOR 3
0017 #define ZMQ_VERSION_PATCH 5
0018 
0019 #define ZMQ_MAKE_VERSION(major, minor, patch)                                  \
0020     ((major) *10000 + (minor) *100 + (patch))
0021 #define ZMQ_VERSION                                                            \
0022     ZMQ_MAKE_VERSION (ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH)
0023 
0024 #ifdef __cplusplus
0025 extern "C" {
0026 #endif
0027 
0028 #if !defined _WIN32_WCE
0029 #include <errno.h>
0030 #endif
0031 #include <stddef.h>
0032 #include <stdio.h>
0033 
0034 /*  Handle DSO symbol visibility                                             */
0035 #if defined ZMQ_NO_EXPORT
0036 #define ZMQ_EXPORT
0037 #else
0038 #if defined _WIN32
0039 #if defined ZMQ_STATIC
0040 #define ZMQ_EXPORT
0041 #elif defined DLL_EXPORT
0042 #define ZMQ_EXPORT __declspec(dllexport)
0043 #else
0044 #define ZMQ_EXPORT __declspec(dllimport)
0045 #endif
0046 #else
0047 #if defined __SUNPRO_C || defined __SUNPRO_CC
0048 #define ZMQ_EXPORT __global
0049 #elif (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER
0050 #define ZMQ_EXPORT __attribute__ ((visibility ("default")))
0051 #else
0052 #define ZMQ_EXPORT
0053 #endif
0054 #endif
0055 #endif
0056 
0057 /*  Define integer types needed for event interface                          */
0058 #define ZMQ_DEFINED_STDINT 1
0059 #if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_OPENVMS
0060 #include <inttypes.h>
0061 #elif defined _MSC_VER && _MSC_VER < 1600
0062 #ifndef uint64_t
0063 typedef unsigned __int64 uint64_t;
0064 #endif
0065 #ifndef int32_t
0066 typedef __int32 int32_t;
0067 #endif
0068 #ifndef uint32_t
0069 typedef unsigned __int32 uint32_t;
0070 #endif
0071 #ifndef uint16_t
0072 typedef unsigned __int16 uint16_t;
0073 #endif
0074 #ifndef uint8_t
0075 typedef unsigned __int8 uint8_t;
0076 #endif
0077 #else
0078 #include <stdint.h>
0079 #endif
0080 
0081 #if !defined _WIN32
0082 // needed for sigset_t definition in zmq_ppoll
0083 #include <signal.h>
0084 #endif
0085 
0086 //  32-bit AIX's pollfd struct members are called reqevents and rtnevents so it
0087 //  defines compatibility macros for them. Need to include that header first to
0088 //  stop build failures since zmq_pollset_t defines them as events and revents.
0089 #ifdef ZMQ_HAVE_AIX
0090 #include <poll.h>
0091 #endif
0092 
0093 
0094 /******************************************************************************/
0095 /*  0MQ errors.                                                               */
0096 /******************************************************************************/
0097 
0098 /*  A number random enough not to collide with different errno ranges on      */
0099 /*  different OSes. The assumption is that error_t is at least 32-bit type.   */
0100 #define ZMQ_HAUSNUMERO 156384712
0101 
0102 /*  On Windows platform some of the standard POSIX errnos are not defined.    */
0103 #ifndef ENOTSUP
0104 #define ENOTSUP (ZMQ_HAUSNUMERO + 1)
0105 #endif
0106 #ifndef EPROTONOSUPPORT
0107 #define EPROTONOSUPPORT (ZMQ_HAUSNUMERO + 2)
0108 #endif
0109 #ifndef ENOBUFS
0110 #define ENOBUFS (ZMQ_HAUSNUMERO + 3)
0111 #endif
0112 #ifndef ENETDOWN
0113 #define ENETDOWN (ZMQ_HAUSNUMERO + 4)
0114 #endif
0115 #ifndef EADDRINUSE
0116 #define EADDRINUSE (ZMQ_HAUSNUMERO + 5)
0117 #endif
0118 #ifndef EADDRNOTAVAIL
0119 #define EADDRNOTAVAIL (ZMQ_HAUSNUMERO + 6)
0120 #endif
0121 #ifndef ECONNREFUSED
0122 #define ECONNREFUSED (ZMQ_HAUSNUMERO + 7)
0123 #endif
0124 #ifndef EINPROGRESS
0125 #define EINPROGRESS (ZMQ_HAUSNUMERO + 8)
0126 #endif
0127 #ifndef ENOTSOCK
0128 #define ENOTSOCK (ZMQ_HAUSNUMERO + 9)
0129 #endif
0130 #ifndef EMSGSIZE
0131 #define EMSGSIZE (ZMQ_HAUSNUMERO + 10)
0132 #endif
0133 #ifndef EAFNOSUPPORT
0134 #define EAFNOSUPPORT (ZMQ_HAUSNUMERO + 11)
0135 #endif
0136 #ifndef ENETUNREACH
0137 #define ENETUNREACH (ZMQ_HAUSNUMERO + 12)
0138 #endif
0139 #ifndef ECONNABORTED
0140 #define ECONNABORTED (ZMQ_HAUSNUMERO + 13)
0141 #endif
0142 #ifndef ECONNRESET
0143 #define ECONNRESET (ZMQ_HAUSNUMERO + 14)
0144 #endif
0145 #ifndef ENOTCONN
0146 #define ENOTCONN (ZMQ_HAUSNUMERO + 15)
0147 #endif
0148 #ifndef ETIMEDOUT
0149 #define ETIMEDOUT (ZMQ_HAUSNUMERO + 16)
0150 #endif
0151 #ifndef EHOSTUNREACH
0152 #define EHOSTUNREACH (ZMQ_HAUSNUMERO + 17)
0153 #endif
0154 #ifndef ENETRESET
0155 #define ENETRESET (ZMQ_HAUSNUMERO + 18)
0156 #endif
0157 
0158 /*  Native 0MQ error codes.                                                   */
0159 #define EFSM (ZMQ_HAUSNUMERO + 51)
0160 #define ENOCOMPATPROTO (ZMQ_HAUSNUMERO + 52)
0161 #define ETERM (ZMQ_HAUSNUMERO + 53)
0162 #define EMTHREAD (ZMQ_HAUSNUMERO + 54)
0163 
0164 /*  This function retrieves the errno as it is known to 0MQ library. The goal */
0165 /*  of this function is to make the code 100% portable, including where 0MQ   */
0166 /*  compiled with certain CRT library (on Windows) is linked to an            */
0167 /*  application that uses different CRT library.                              */
0168 ZMQ_EXPORT int zmq_errno (void);
0169 
0170 /*  Resolves system errors and 0MQ errors to human-readable string.           */
0171 ZMQ_EXPORT const char *zmq_strerror (int errnum_);
0172 
0173 /*  Run-time API version detection                                            */
0174 ZMQ_EXPORT void zmq_version (int *major_, int *minor_, int *patch_);
0175 
0176 /******************************************************************************/
0177 /*  0MQ infrastructure (a.k.a. context) initialisation & termination.         */
0178 /******************************************************************************/
0179 
0180 /*  Context options                                                           */
0181 #define ZMQ_IO_THREADS 1
0182 #define ZMQ_MAX_SOCKETS 2
0183 #define ZMQ_SOCKET_LIMIT 3
0184 #define ZMQ_THREAD_PRIORITY 3
0185 #define ZMQ_THREAD_SCHED_POLICY 4
0186 #define ZMQ_MAX_MSGSZ 5
0187 #define ZMQ_MSG_T_SIZE 6
0188 #define ZMQ_THREAD_AFFINITY_CPU_ADD 7
0189 #define ZMQ_THREAD_AFFINITY_CPU_REMOVE 8
0190 #define ZMQ_THREAD_NAME_PREFIX 9
0191 
0192 /*  Default for new contexts                                                  */
0193 #define ZMQ_IO_THREADS_DFLT 1
0194 #define ZMQ_MAX_SOCKETS_DFLT 1023
0195 #define ZMQ_THREAD_PRIORITY_DFLT -1
0196 #define ZMQ_THREAD_SCHED_POLICY_DFLT -1
0197 
0198 ZMQ_EXPORT void *zmq_ctx_new (void);
0199 ZMQ_EXPORT int zmq_ctx_term (void *context_);
0200 ZMQ_EXPORT int zmq_ctx_shutdown (void *context_);
0201 ZMQ_EXPORT int zmq_ctx_set (void *context_, int option_, int optval_);
0202 ZMQ_EXPORT int zmq_ctx_get (void *context_, int option_);
0203 
0204 /*  Old (legacy) API                                                          */
0205 ZMQ_EXPORT void *zmq_init (int io_threads_);
0206 ZMQ_EXPORT int zmq_term (void *context_);
0207 ZMQ_EXPORT int zmq_ctx_destroy (void *context_);
0208 
0209 
0210 /******************************************************************************/
0211 /*  0MQ message definition.                                                   */
0212 /******************************************************************************/
0213 
0214 /* Some architectures, like sparc64 and some variants of aarch64, enforce pointer
0215  * alignment and raise sigbus on violations. Make sure applications allocate
0216  * zmq_msg_t on addresses aligned on a pointer-size boundary to avoid this issue.
0217  */
0218 typedef struct zmq_msg_t
0219 {
0220 #if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_ARM64))
0221     __declspec(align (8)) unsigned char _[64];
0222 #elif defined(_MSC_VER)                                                        \
0223   && (defined(_M_IX86) || defined(_M_ARM_ARMV7VE) || defined(_M_ARM))
0224     __declspec(align (4)) unsigned char _[64];
0225 #elif defined(__GNUC__) || defined(__INTEL_COMPILER)                           \
0226   || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x590)                              \
0227   || (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x590)
0228     unsigned char _[64] __attribute__ ((aligned (sizeof (void *))));
0229 #else
0230     unsigned char _[64];
0231 #endif
0232 } zmq_msg_t;
0233 
0234 typedef void (zmq_free_fn) (void *data_, void *hint_);
0235 
0236 ZMQ_EXPORT int zmq_msg_init (zmq_msg_t *msg_);
0237 ZMQ_EXPORT int zmq_msg_init_size (zmq_msg_t *msg_, size_t size_);
0238 ZMQ_EXPORT int zmq_msg_init_data (
0239   zmq_msg_t *msg_, void *data_, size_t size_, zmq_free_fn *ffn_, void *hint_);
0240 ZMQ_EXPORT int zmq_msg_send (zmq_msg_t *msg_, void *s_, int flags_);
0241 ZMQ_EXPORT int zmq_msg_recv (zmq_msg_t *msg_, void *s_, int flags_);
0242 ZMQ_EXPORT int zmq_msg_close (zmq_msg_t *msg_);
0243 ZMQ_EXPORT int zmq_msg_move (zmq_msg_t *dest_, zmq_msg_t *src_);
0244 ZMQ_EXPORT int zmq_msg_copy (zmq_msg_t *dest_, zmq_msg_t *src_);
0245 ZMQ_EXPORT void *zmq_msg_data (zmq_msg_t *msg_);
0246 ZMQ_EXPORT size_t zmq_msg_size (const zmq_msg_t *msg_);
0247 ZMQ_EXPORT int zmq_msg_more (const zmq_msg_t *msg_);
0248 ZMQ_EXPORT int zmq_msg_get (const zmq_msg_t *msg_, int property_);
0249 ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg_, int property_, int optval_);
0250 ZMQ_EXPORT const char *zmq_msg_gets (const zmq_msg_t *msg_,
0251                                      const char *property_);
0252 
0253 /******************************************************************************/
0254 /*  0MQ socket definition.                                                    */
0255 /******************************************************************************/
0256 
0257 /*  Socket types.                                                             */
0258 #define ZMQ_PAIR 0
0259 #define ZMQ_PUB 1
0260 #define ZMQ_SUB 2
0261 #define ZMQ_REQ 3
0262 #define ZMQ_REP 4
0263 #define ZMQ_DEALER 5
0264 #define ZMQ_ROUTER 6
0265 #define ZMQ_PULL 7
0266 #define ZMQ_PUSH 8
0267 #define ZMQ_XPUB 9
0268 #define ZMQ_XSUB 10
0269 #define ZMQ_STREAM 11
0270 
0271 /*  Deprecated aliases                                                        */
0272 #define ZMQ_XREQ ZMQ_DEALER
0273 #define ZMQ_XREP ZMQ_ROUTER
0274 
0275 /*  Socket options.                                                           */
0276 #define ZMQ_AFFINITY 4
0277 #define ZMQ_ROUTING_ID 5
0278 #define ZMQ_SUBSCRIBE 6
0279 #define ZMQ_UNSUBSCRIBE 7
0280 #define ZMQ_RATE 8
0281 #define ZMQ_RECOVERY_IVL 9
0282 #define ZMQ_SNDBUF 11
0283 #define ZMQ_RCVBUF 12
0284 #define ZMQ_RCVMORE 13
0285 #define ZMQ_FD 14
0286 #define ZMQ_EVENTS 15
0287 #define ZMQ_TYPE 16
0288 #define ZMQ_LINGER 17
0289 #define ZMQ_RECONNECT_IVL 18
0290 #define ZMQ_BACKLOG 19
0291 #define ZMQ_RECONNECT_IVL_MAX 21
0292 #define ZMQ_MAXMSGSIZE 22
0293 #define ZMQ_SNDHWM 23
0294 #define ZMQ_RCVHWM 24
0295 #define ZMQ_MULTICAST_HOPS 25
0296 #define ZMQ_RCVTIMEO 27
0297 #define ZMQ_SNDTIMEO 28
0298 #define ZMQ_LAST_ENDPOINT 32
0299 #define ZMQ_ROUTER_MANDATORY 33
0300 #define ZMQ_TCP_KEEPALIVE 34
0301 #define ZMQ_TCP_KEEPALIVE_CNT 35
0302 #define ZMQ_TCP_KEEPALIVE_IDLE 36
0303 #define ZMQ_TCP_KEEPALIVE_INTVL 37
0304 #define ZMQ_IMMEDIATE 39
0305 #define ZMQ_XPUB_VERBOSE 40
0306 #define ZMQ_ROUTER_RAW 41
0307 #define ZMQ_IPV6 42
0308 #define ZMQ_MECHANISM 43
0309 #define ZMQ_PLAIN_SERVER 44
0310 #define ZMQ_PLAIN_USERNAME 45
0311 #define ZMQ_PLAIN_PASSWORD 46
0312 #define ZMQ_CURVE_SERVER 47
0313 #define ZMQ_CURVE_PUBLICKEY 48
0314 #define ZMQ_CURVE_SECRETKEY 49
0315 #define ZMQ_CURVE_SERVERKEY 50
0316 #define ZMQ_PROBE_ROUTER 51
0317 #define ZMQ_REQ_CORRELATE 52
0318 #define ZMQ_REQ_RELAXED 53
0319 #define ZMQ_CONFLATE 54
0320 #define ZMQ_ZAP_DOMAIN 55
0321 #define ZMQ_ROUTER_HANDOVER 56
0322 #define ZMQ_TOS 57
0323 #define ZMQ_CONNECT_ROUTING_ID 61
0324 #define ZMQ_GSSAPI_SERVER 62
0325 #define ZMQ_GSSAPI_PRINCIPAL 63
0326 #define ZMQ_GSSAPI_SERVICE_PRINCIPAL 64
0327 #define ZMQ_GSSAPI_PLAINTEXT 65
0328 #define ZMQ_HANDSHAKE_IVL 66
0329 #define ZMQ_SOCKS_PROXY 68
0330 #define ZMQ_XPUB_NODROP 69
0331 #define ZMQ_BLOCKY 70
0332 #define ZMQ_XPUB_MANUAL 71
0333 #define ZMQ_XPUB_WELCOME_MSG 72
0334 #define ZMQ_STREAM_NOTIFY 73
0335 #define ZMQ_INVERT_MATCHING 74
0336 #define ZMQ_HEARTBEAT_IVL 75
0337 #define ZMQ_HEARTBEAT_TTL 76
0338 #define ZMQ_HEARTBEAT_TIMEOUT 77
0339 #define ZMQ_XPUB_VERBOSER 78
0340 #define ZMQ_CONNECT_TIMEOUT 79
0341 #define ZMQ_TCP_MAXRT 80
0342 #define ZMQ_THREAD_SAFE 81
0343 #define ZMQ_MULTICAST_MAXTPDU 84
0344 #define ZMQ_VMCI_BUFFER_SIZE 85
0345 #define ZMQ_VMCI_BUFFER_MIN_SIZE 86
0346 #define ZMQ_VMCI_BUFFER_MAX_SIZE 87
0347 #define ZMQ_VMCI_CONNECT_TIMEOUT 88
0348 #define ZMQ_USE_FD 89
0349 #define ZMQ_GSSAPI_PRINCIPAL_NAMETYPE 90
0350 #define ZMQ_GSSAPI_SERVICE_PRINCIPAL_NAMETYPE 91
0351 #define ZMQ_BINDTODEVICE 92
0352 
0353 /*  Message options                                                           */
0354 #define ZMQ_MORE 1
0355 #define ZMQ_SHARED 3
0356 
0357 /*  Send/recv options.                                                        */
0358 #define ZMQ_DONTWAIT 1
0359 #define ZMQ_SNDMORE 2
0360 
0361 /*  Security mechanisms                                                       */
0362 #define ZMQ_NULL 0
0363 #define ZMQ_PLAIN 1
0364 #define ZMQ_CURVE 2
0365 #define ZMQ_GSSAPI 3
0366 
0367 /*  RADIO-DISH protocol                                                       */
0368 #define ZMQ_GROUP_MAX_LENGTH 255
0369 
0370 /*  Deprecated options and aliases                                            */
0371 #define ZMQ_IDENTITY ZMQ_ROUTING_ID
0372 #define ZMQ_CONNECT_RID ZMQ_CONNECT_ROUTING_ID
0373 #define ZMQ_TCP_ACCEPT_FILTER 38
0374 #define ZMQ_IPC_FILTER_PID 58
0375 #define ZMQ_IPC_FILTER_UID 59
0376 #define ZMQ_IPC_FILTER_GID 60
0377 #define ZMQ_IPV4ONLY 31
0378 #define ZMQ_DELAY_ATTACH_ON_CONNECT ZMQ_IMMEDIATE
0379 #define ZMQ_NOBLOCK ZMQ_DONTWAIT
0380 #define ZMQ_FAIL_UNROUTABLE ZMQ_ROUTER_MANDATORY
0381 #define ZMQ_ROUTER_BEHAVIOR ZMQ_ROUTER_MANDATORY
0382 
0383 /*  Deprecated Message options                                                */
0384 #define ZMQ_SRCFD 2
0385 
0386 /******************************************************************************/
0387 /*  GSSAPI definitions                                                        */
0388 /******************************************************************************/
0389 
0390 /*  GSSAPI principal name types                                               */
0391 #define ZMQ_GSSAPI_NT_HOSTBASED 0
0392 #define ZMQ_GSSAPI_NT_USER_NAME 1
0393 #define ZMQ_GSSAPI_NT_KRB5_PRINCIPAL 2
0394 
0395 /******************************************************************************/
0396 /*  0MQ socket events and monitoring                                          */
0397 /******************************************************************************/
0398 
0399 /*  Socket transport events (TCP, IPC and TIPC only)                          */
0400 
0401 #define ZMQ_EVENT_CONNECTED 0x0001
0402 #define ZMQ_EVENT_CONNECT_DELAYED 0x0002
0403 #define ZMQ_EVENT_CONNECT_RETRIED 0x0004
0404 #define ZMQ_EVENT_LISTENING 0x0008
0405 #define ZMQ_EVENT_BIND_FAILED 0x0010
0406 #define ZMQ_EVENT_ACCEPTED 0x0020
0407 #define ZMQ_EVENT_ACCEPT_FAILED 0x0040
0408 #define ZMQ_EVENT_CLOSED 0x0080
0409 #define ZMQ_EVENT_CLOSE_FAILED 0x0100
0410 #define ZMQ_EVENT_DISCONNECTED 0x0200
0411 #define ZMQ_EVENT_MONITOR_STOPPED 0x0400
0412 #define ZMQ_EVENT_ALL 0xFFFF
0413 /*  Unspecified system errors during handshake. Event value is an errno.      */
0414 #define ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL 0x0800
0415 /*  Handshake complete successfully with successful authentication (if        *
0416  *  enabled). Event value is unused.                                          */
0417 #define ZMQ_EVENT_HANDSHAKE_SUCCEEDED 0x1000
0418 /*  Protocol errors between ZMTP peers or between server and ZAP handler.     *
0419  *  Event value is one of ZMQ_PROTOCOL_ERROR_*                                */
0420 #define ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL 0x2000
0421 /*  Failed authentication requests. Event value is the numeric ZAP status     *
0422  *  code, i.e. 300, 400 or 500.                                               */
0423 #define ZMQ_EVENT_HANDSHAKE_FAILED_AUTH 0x4000
0424 #define ZMQ_PROTOCOL_ERROR_ZMTP_UNSPECIFIED 0x10000000
0425 #define ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND 0x10000001
0426 #define ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_SEQUENCE 0x10000002
0427 #define ZMQ_PROTOCOL_ERROR_ZMTP_KEY_EXCHANGE 0x10000003
0428 #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_UNSPECIFIED 0x10000011
0429 #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_MESSAGE 0x10000012
0430 #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO 0x10000013
0431 #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_INITIATE 0x10000014
0432 #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR 0x10000015
0433 #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_READY 0x10000016
0434 #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_WELCOME 0x10000017
0435 #define ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_METADATA 0x10000018
0436 // the following two may be due to erroneous configuration of a peer
0437 #define ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC 0x11000001
0438 #define ZMQ_PROTOCOL_ERROR_ZMTP_MECHANISM_MISMATCH 0x11000002
0439 #define ZMQ_PROTOCOL_ERROR_ZAP_UNSPECIFIED 0x20000000
0440 #define ZMQ_PROTOCOL_ERROR_ZAP_MALFORMED_REPLY 0x20000001
0441 #define ZMQ_PROTOCOL_ERROR_ZAP_BAD_REQUEST_ID 0x20000002
0442 #define ZMQ_PROTOCOL_ERROR_ZAP_BAD_VERSION 0x20000003
0443 #define ZMQ_PROTOCOL_ERROR_ZAP_INVALID_STATUS_CODE 0x20000004
0444 #define ZMQ_PROTOCOL_ERROR_ZAP_INVALID_METADATA 0x20000005
0445 #define ZMQ_PROTOCOL_ERROR_WS_UNSPECIFIED 0x30000000
0446 
0447 ZMQ_EXPORT void *zmq_socket (void *, int type_);
0448 ZMQ_EXPORT int zmq_close (void *s_);
0449 ZMQ_EXPORT int
0450 zmq_setsockopt (void *s_, int option_, const void *optval_, size_t optvallen_);
0451 ZMQ_EXPORT int
0452 zmq_getsockopt (void *s_, int option_, void *optval_, size_t *optvallen_);
0453 ZMQ_EXPORT int zmq_bind (void *s_, const char *addr_);
0454 ZMQ_EXPORT int zmq_connect (void *s_, const char *addr_);
0455 ZMQ_EXPORT int zmq_unbind (void *s_, const char *addr_);
0456 ZMQ_EXPORT int zmq_disconnect (void *s_, const char *addr_);
0457 ZMQ_EXPORT int zmq_send (void *s_, const void *buf_, size_t len_, int flags_);
0458 ZMQ_EXPORT int
0459 zmq_send_const (void *s_, const void *buf_, size_t len_, int flags_);
0460 ZMQ_EXPORT int zmq_recv (void *s_, void *buf_, size_t len_, int flags_);
0461 ZMQ_EXPORT int zmq_socket_monitor (void *s_, const char *addr_, int events_);
0462 
0463 /******************************************************************************/
0464 /*  Hide socket fd type; this was before zmq_poller_event_t typedef below     */
0465 /******************************************************************************/
0466 
0467 #if defined _WIN32
0468 // Windows uses a pointer-sized unsigned integer to store the socket fd.
0469 #if defined _WIN64
0470 typedef unsigned __int64 zmq_fd_t;
0471 #else
0472 typedef unsigned int zmq_fd_t;
0473 #endif
0474 #else
0475 typedef int zmq_fd_t;
0476 #endif
0477 
0478 /******************************************************************************/
0479 /*  Deprecated I/O multiplexing. Prefer using zmq_poller API                  */
0480 /******************************************************************************/
0481 
0482 #define ZMQ_POLLIN 1
0483 #define ZMQ_POLLOUT 2
0484 #define ZMQ_POLLERR 4
0485 #define ZMQ_POLLPRI 8
0486 
0487 typedef struct zmq_pollitem_t
0488 {
0489     void *socket;
0490     zmq_fd_t fd;
0491     short events;
0492     short revents;
0493 } zmq_pollitem_t;
0494 
0495 #define ZMQ_POLLITEMS_DFLT 16
0496 
0497 ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_);
0498 
0499 /******************************************************************************/
0500 /*  Message proxying                                                          */
0501 /******************************************************************************/
0502 
0503 ZMQ_EXPORT int zmq_proxy (void *frontend_, void *backend_, void *capture_);
0504 ZMQ_EXPORT int zmq_proxy_steerable (void *frontend_,
0505                                     void *backend_,
0506                                     void *capture_,
0507                                     void *control_);
0508 
0509 /******************************************************************************/
0510 /*  Probe library capabilities                                                */
0511 /******************************************************************************/
0512 
0513 #define ZMQ_HAS_CAPABILITIES 1
0514 ZMQ_EXPORT int zmq_has (const char *capability_);
0515 
0516 /*  Deprecated aliases */
0517 #define ZMQ_STREAMER 1
0518 #define ZMQ_FORWARDER 2
0519 #define ZMQ_QUEUE 3
0520 
0521 /*  Deprecated methods */
0522 ZMQ_EXPORT int zmq_device (int type_, void *frontend_, void *backend_);
0523 ZMQ_EXPORT int zmq_sendmsg (void *s_, zmq_msg_t *msg_, int flags_);
0524 ZMQ_EXPORT int zmq_recvmsg (void *s_, zmq_msg_t *msg_, int flags_);
0525 struct iovec;
0526 ZMQ_EXPORT int
0527 zmq_sendiov (void *s_, struct iovec *iov_, size_t count_, int flags_);
0528 ZMQ_EXPORT int
0529 zmq_recviov (void *s_, struct iovec *iov_, size_t *count_, int flags_);
0530 
0531 /******************************************************************************/
0532 /*  Encryption functions                                                      */
0533 /******************************************************************************/
0534 
0535 /*  Encode data with Z85 encoding. Returns encoded data                       */
0536 ZMQ_EXPORT char *
0537 zmq_z85_encode (char *dest_, const uint8_t *data_, size_t size_);
0538 
0539 /*  Decode data with Z85 encoding. Returns decoded data                       */
0540 ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest_, const char *string_);
0541 
0542 /*  Generate z85-encoded public and private keypair with libsodium. */
0543 /*  Returns 0 on success.                                                     */
0544 ZMQ_EXPORT int zmq_curve_keypair (char *z85_public_key_, char *z85_secret_key_);
0545 
0546 /*  Derive the z85-encoded public key from the z85-encoded secret key.        */
0547 /*  Returns 0 on success.                                                     */
0548 ZMQ_EXPORT int zmq_curve_public (char *z85_public_key_,
0549                                  const char *z85_secret_key_);
0550 
0551 /******************************************************************************/
0552 /*  Atomic utility methods                                                    */
0553 /******************************************************************************/
0554 
0555 ZMQ_EXPORT void *zmq_atomic_counter_new (void);
0556 ZMQ_EXPORT void zmq_atomic_counter_set (void *counter_, int value_);
0557 ZMQ_EXPORT int zmq_atomic_counter_inc (void *counter_);
0558 ZMQ_EXPORT int zmq_atomic_counter_dec (void *counter_);
0559 ZMQ_EXPORT int zmq_atomic_counter_value (void *counter_);
0560 ZMQ_EXPORT void zmq_atomic_counter_destroy (void **counter_p_);
0561 
0562 /******************************************************************************/
0563 /*  Scheduling timers                                                         */
0564 /******************************************************************************/
0565 
0566 #define ZMQ_HAVE_TIMERS
0567 
0568 typedef void (zmq_timer_fn) (int timer_id, void *arg);
0569 
0570 ZMQ_EXPORT void *zmq_timers_new (void);
0571 ZMQ_EXPORT int zmq_timers_destroy (void **timers_p);
0572 ZMQ_EXPORT int
0573 zmq_timers_add (void *timers, size_t interval, zmq_timer_fn handler, void *arg);
0574 ZMQ_EXPORT int zmq_timers_cancel (void *timers, int timer_id);
0575 ZMQ_EXPORT int
0576 zmq_timers_set_interval (void *timers, int timer_id, size_t interval);
0577 ZMQ_EXPORT int zmq_timers_reset (void *timers, int timer_id);
0578 ZMQ_EXPORT long zmq_timers_timeout (void *timers);
0579 ZMQ_EXPORT int zmq_timers_execute (void *timers);
0580 
0581 
0582 /******************************************************************************/
0583 /*  These functions are not documented by man pages -- use at your own risk.  */
0584 /*  If you need these to be part of the formal ZMQ API, then (a) write a man  */
0585 /*  page, and (b) write a test case in tests.                                 */
0586 /******************************************************************************/
0587 
0588 /*  Helper functions are used by perf tests so that they don't have to care   */
0589 /*  about minutiae of time-related functions on different OS platforms.       */
0590 
0591 /*  Starts the stopwatch. Returns the handle to the watch.                    */
0592 ZMQ_EXPORT void *zmq_stopwatch_start (void);
0593 
0594 /*  Returns the number of microseconds elapsed since the stopwatch was        */
0595 /*  started, but does not stop or deallocate the stopwatch.                   */
0596 ZMQ_EXPORT unsigned long zmq_stopwatch_intermediate (void *watch_);
0597 
0598 /*  Stops the stopwatch. Returns the number of microseconds elapsed since     */
0599 /*  the stopwatch was started, and deallocates that watch.                    */
0600 ZMQ_EXPORT unsigned long zmq_stopwatch_stop (void *watch_);
0601 
0602 /*  Sleeps for specified number of seconds.                                   */
0603 ZMQ_EXPORT void zmq_sleep (int seconds_);
0604 
0605 typedef void (zmq_thread_fn) (void *);
0606 
0607 /* Start a thread. Returns a handle to the thread.                            */
0608 ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn *func_, void *arg_);
0609 
0610 /* Wait for thread to complete then free up resources.                        */
0611 ZMQ_EXPORT void zmq_threadclose (void *thread_);
0612 
0613 
0614 /******************************************************************************/
0615 /*  These functions are DRAFT and disabled in stable releases, and subject to */
0616 /*  change at ANY time until declared stable.                                 */
0617 /******************************************************************************/
0618 
0619 #ifdef ZMQ_BUILD_DRAFT_API
0620 
0621 /*  DRAFT Socket types.                                                       */
0622 #define ZMQ_SERVER 12
0623 #define ZMQ_CLIENT 13
0624 #define ZMQ_RADIO 14
0625 #define ZMQ_DISH 15
0626 #define ZMQ_GATHER 16
0627 #define ZMQ_SCATTER 17
0628 #define ZMQ_DGRAM 18
0629 #define ZMQ_PEER 19
0630 #define ZMQ_CHANNEL 20
0631 
0632 /*  DRAFT Socket options.                                                     */
0633 #define ZMQ_ZAP_ENFORCE_DOMAIN 93
0634 #define ZMQ_LOOPBACK_FASTPATH 94
0635 #define ZMQ_METADATA 95
0636 #define ZMQ_MULTICAST_LOOP 96
0637 #define ZMQ_ROUTER_NOTIFY 97
0638 #define ZMQ_XPUB_MANUAL_LAST_VALUE 98
0639 #define ZMQ_SOCKS_USERNAME 99
0640 #define ZMQ_SOCKS_PASSWORD 100
0641 #define ZMQ_IN_BATCH_SIZE 101
0642 #define ZMQ_OUT_BATCH_SIZE 102
0643 #define ZMQ_WSS_KEY_PEM 103
0644 #define ZMQ_WSS_CERT_PEM 104
0645 #define ZMQ_WSS_TRUST_PEM 105
0646 #define ZMQ_WSS_HOSTNAME 106
0647 #define ZMQ_WSS_TRUST_SYSTEM 107
0648 #define ZMQ_ONLY_FIRST_SUBSCRIBE 108
0649 #define ZMQ_RECONNECT_STOP 109
0650 #define ZMQ_HELLO_MSG 110
0651 #define ZMQ_DISCONNECT_MSG 111
0652 #define ZMQ_PRIORITY 112
0653 #define ZMQ_BUSY_POLL 113
0654 #define ZMQ_HICCUP_MSG 114
0655 #define ZMQ_XSUB_VERBOSE_UNSUBSCRIBE 115
0656 #define ZMQ_TOPICS_COUNT 116
0657 #define ZMQ_NORM_MODE 117
0658 #define ZMQ_NORM_UNICAST_NACK 118
0659 #define ZMQ_NORM_BUFFER_SIZE 119
0660 #define ZMQ_NORM_SEGMENT_SIZE 120
0661 #define ZMQ_NORM_BLOCK_SIZE 121
0662 #define ZMQ_NORM_NUM_PARITY 122
0663 #define ZMQ_NORM_NUM_AUTOPARITY 123
0664 #define ZMQ_NORM_PUSH 124
0665 
0666 /*  DRAFT ZMQ_NORM_MODE options                                               */
0667 #define ZMQ_NORM_FIXED 0
0668 #define ZMQ_NORM_CC 1
0669 #define ZMQ_NORM_CCL 2
0670 #define ZMQ_NORM_CCE 3
0671 #define ZMQ_NORM_CCE_ECNONLY 4
0672 
0673 /*  DRAFT ZMQ_RECONNECT_STOP options                                          */
0674 #define ZMQ_RECONNECT_STOP_CONN_REFUSED 0x1
0675 #define ZMQ_RECONNECT_STOP_HANDSHAKE_FAILED 0x2
0676 #define ZMQ_RECONNECT_STOP_AFTER_DISCONNECT 0x4
0677 
0678 /*  DRAFT Context options                                                     */
0679 #define ZMQ_ZERO_COPY_RECV 10
0680 
0681 /*  DRAFT Context methods.                                                    */
0682 ZMQ_EXPORT int zmq_ctx_set_ext (void *context_,
0683                                 int option_,
0684                                 const void *optval_,
0685                                 size_t optvallen_);
0686 ZMQ_EXPORT int zmq_ctx_get_ext (void *context_,
0687                                 int option_,
0688                                 void *optval_,
0689                                 size_t *optvallen_);
0690 
0691 /*  DRAFT Socket methods.                                                     */
0692 ZMQ_EXPORT int zmq_join (void *s, const char *group);
0693 ZMQ_EXPORT int zmq_leave (void *s, const char *group);
0694 ZMQ_EXPORT uint32_t zmq_connect_peer (void *s_, const char *addr_);
0695 
0696 /*  DRAFT Msg methods.                                                        */
0697 ZMQ_EXPORT int zmq_msg_set_routing_id (zmq_msg_t *msg, uint32_t routing_id);
0698 ZMQ_EXPORT uint32_t zmq_msg_routing_id (zmq_msg_t *msg);
0699 ZMQ_EXPORT int zmq_msg_set_group (zmq_msg_t *msg, const char *group);
0700 ZMQ_EXPORT const char *zmq_msg_group (zmq_msg_t *msg);
0701 ZMQ_EXPORT int
0702 zmq_msg_init_buffer (zmq_msg_t *msg_, const void *buf_, size_t size_);
0703 
0704 /*  DRAFT Msg property names.                                                 */
0705 #define ZMQ_MSG_PROPERTY_ROUTING_ID "Routing-Id"
0706 #define ZMQ_MSG_PROPERTY_SOCKET_TYPE "Socket-Type"
0707 #define ZMQ_MSG_PROPERTY_USER_ID "User-Id"
0708 #define ZMQ_MSG_PROPERTY_PEER_ADDRESS "Peer-Address"
0709 
0710 /*  Router notify options                                                     */
0711 #define ZMQ_NOTIFY_CONNECT 1
0712 #define ZMQ_NOTIFY_DISCONNECT 2
0713 
0714 /******************************************************************************/
0715 /*  Poller polling on sockets,fd and thread-safe sockets                      */
0716 /******************************************************************************/
0717 
0718 #define ZMQ_HAVE_POLLER
0719 
0720 typedef struct zmq_poller_event_t
0721 {
0722     void *socket;
0723     zmq_fd_t fd;
0724     void *user_data;
0725     short events;
0726 } zmq_poller_event_t;
0727 
0728 ZMQ_EXPORT void *zmq_poller_new (void);
0729 ZMQ_EXPORT int zmq_poller_destroy (void **poller_p);
0730 ZMQ_EXPORT int zmq_poller_size (void *poller);
0731 ZMQ_EXPORT int
0732 zmq_poller_add (void *poller, void *socket, void *user_data, short events);
0733 ZMQ_EXPORT int zmq_poller_modify (void *poller, void *socket, short events);
0734 ZMQ_EXPORT int zmq_poller_remove (void *poller, void *socket);
0735 ZMQ_EXPORT int
0736 zmq_poller_wait (void *poller, zmq_poller_event_t *event, long timeout);
0737 ZMQ_EXPORT int zmq_poller_wait_all (void *poller,
0738                                     zmq_poller_event_t *events,
0739                                     int n_events,
0740                                     long timeout);
0741 ZMQ_EXPORT int zmq_poller_fd (void *poller, zmq_fd_t *fd);
0742 
0743 ZMQ_EXPORT int
0744 zmq_poller_add_fd (void *poller, zmq_fd_t fd, void *user_data, short events);
0745 ZMQ_EXPORT int zmq_poller_modify_fd (void *poller, zmq_fd_t fd, short events);
0746 ZMQ_EXPORT int zmq_poller_remove_fd (void *poller, zmq_fd_t fd);
0747 
0748 ZMQ_EXPORT int zmq_socket_get_peer_state (void *socket,
0749                                           const void *routing_id,
0750                                           size_t routing_id_size);
0751 
0752 /*  DRAFT Socket monitoring events                                            */
0753 #define ZMQ_EVENT_PIPES_STATS 0x10000
0754 
0755 #define ZMQ_CURRENT_EVENT_VERSION 1
0756 #define ZMQ_CURRENT_EVENT_VERSION_DRAFT 2
0757 
0758 #define ZMQ_EVENT_ALL_V1 ZMQ_EVENT_ALL
0759 #define ZMQ_EVENT_ALL_V2 ZMQ_EVENT_ALL_V1 | ZMQ_EVENT_PIPES_STATS
0760 
0761 ZMQ_EXPORT int zmq_socket_monitor_versioned (
0762   void *s_, const char *addr_, uint64_t events_, int event_version_, int type_);
0763 ZMQ_EXPORT int zmq_socket_monitor_pipes_stats (void *s);
0764 
0765 #if !defined _WIN32
0766 ZMQ_EXPORT int zmq_ppoll (zmq_pollitem_t *items_,
0767                           int nitems_,
0768                           long timeout_,
0769                           const sigset_t *sigmask_);
0770 #else
0771 // Windows has no sigset_t
0772 ZMQ_EXPORT int zmq_ppoll (zmq_pollitem_t *items_,
0773                           int nitems_,
0774                           long timeout_,
0775                           const void *sigmask_);
0776 #endif
0777 
0778 #endif // ZMQ_BUILD_DRAFT_API
0779 
0780 
0781 #undef ZMQ_EXPORT
0782 
0783 #ifdef __cplusplus
0784 }
0785 #endif
0786 
0787 #endif