/[eiffelstudio]/branches/eth/eve/Src/library/zeromq/spec/include/zmq.h
ViewVC logotype

Contents of /branches/eth/eve/Src/library/zeromq/spec/include/zmq.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 92811 - (show annotations)
Fri Jul 26 04:35:53 2013 UTC (6 years, 2 months ago) by jasonw
File MIME type: text/plain
File size: 12898 byte(s)
<<Merged from trunk#92810.>>
1 /*
2 Copyright (c) 2007-2012 iMatix Corporation
3 Copyright (c) 2009-2011 250bpm s.r.o.
4 Copyright (c) 2011 VMware, Inc.
5 Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
6
7 This file is part of 0MQ.
8
9 0MQ is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 0MQ is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #ifndef __ZMQ_H_INCLUDED__
24 #define __ZMQ_H_INCLUDED__
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #if !defined WINCE
31 #include <errno.h>
32 #endif
33 #include <stddef.h>
34 #include <stdio.h>
35 #if defined _WIN32
36 #include <winsock2.h>
37 #endif
38
39 /* Handle DSO symbol visibility */
40 #if defined _WIN32
41 # if defined DLL_EXPORT
42 # define ZMQ_EXPORT __declspec(dllexport)
43 # else
44 # define ZMQ_EXPORT __declspec(dllimport)
45 # endif
46 #else
47 # if defined __SUNPRO_C || defined __SUNPRO_CC
48 # define ZMQ_EXPORT __global
49 # elif (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER
50 # define ZMQ_EXPORT __attribute__ ((visibility("default")))
51 # else
52 # define ZMQ_EXPORT
53 # endif
54 #endif
55
56 /******************************************************************************/
57 /* 0MQ versioning support. */
58 /******************************************************************************/
59
60 /* Version macros for compile-time API version detection */
61 #define ZMQ_VERSION_MAJOR 3
62 #define ZMQ_VERSION_MINOR 2
63 #define ZMQ_VERSION_PATCH 3
64
65 #define ZMQ_MAKE_VERSION(major, minor, patch) \
66 ((major) * 10000 + (minor) * 100 + (patch))
67 #define ZMQ_VERSION \
68 ZMQ_MAKE_VERSION(ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH)
69
70 /* Run-time API version detection */
71 ZMQ_EXPORT void zmq_version (int *major, int *minor, int *patch);
72
73 /******************************************************************************/
74 /* 0MQ errors. */
75 /******************************************************************************/
76
77 /* A number random enough not to collide with different errno ranges on */
78 /* different OSes. The assumption is that error_t is at least 32-bit type. */
79 #define ZMQ_HAUSNUMERO 156384712
80
81 /* On Windows platform some of the standard POSIX errnos are not defined. */
82 #ifndef ENOTSUP
83 #define ENOTSUP (ZMQ_HAUSNUMERO + 1)
84 #endif
85 #ifndef EPROTONOSUPPORT
86 #define EPROTONOSUPPORT (ZMQ_HAUSNUMERO + 2)
87 #endif
88 #ifndef ENOBUFS
89 #define ENOBUFS (ZMQ_HAUSNUMERO + 3)
90 #endif
91 #ifndef ENETDOWN
92 #define ENETDOWN (ZMQ_HAUSNUMERO + 4)
93 #endif
94 #ifndef EADDRINUSE
95 #define EADDRINUSE (ZMQ_HAUSNUMERO + 5)
96 #endif
97 #ifndef EADDRNOTAVAIL
98 #define EADDRNOTAVAIL (ZMQ_HAUSNUMERO + 6)
99 #endif
100 #ifndef ECONNREFUSED
101 #define ECONNREFUSED (ZMQ_HAUSNUMERO + 7)
102 #endif
103 #ifndef EINPROGRESS
104 #define EINPROGRESS (ZMQ_HAUSNUMERO + 8)
105 #endif
106 #ifndef ENOTSOCK
107 #define ENOTSOCK (ZMQ_HAUSNUMERO + 9)
108 #endif
109 #ifndef EMSGSIZE
110 #define EMSGSIZE (ZMQ_HAUSNUMERO + 10)
111 #endif
112 #ifndef EAFNOSUPPORT
113 #define EAFNOSUPPORT (ZMQ_HAUSNUMERO + 11)
114 #endif
115 #ifndef ENETUNREACH
116 #define ENETUNREACH (ZMQ_HAUSNUMERO + 12)
117 #endif
118 #ifndef ECONNABORTED
119 #define ECONNABORTED (ZMQ_HAUSNUMERO + 13)
120 #endif
121 #ifndef ECONNRESET
122 #define ECONNRESET (ZMQ_HAUSNUMERO + 14)
123 #endif
124 #ifndef ENOTCONN
125 #define ENOTCONN (ZMQ_HAUSNUMERO + 15)
126 #endif
127 #ifndef ETIMEDOUT
128 #define ETIMEDOUT (ZMQ_HAUSNUMERO + 16)
129 #endif
130 #ifndef EHOSTUNREACH
131 #define EHOSTUNREACH (ZMQ_HAUSNUMERO + 17)
132 #endif
133 #ifndef ENETRESET
134 #define ENETRESET (ZMQ_HAUSNUMERO + 18)
135 #endif
136
137 /* Native 0MQ error codes. */
138 #define EFSM (ZMQ_HAUSNUMERO + 51)
139 #define ENOCOMPATPROTO (ZMQ_HAUSNUMERO + 52)
140 #define ETERM (ZMQ_HAUSNUMERO + 53)
141 #define EMTHREAD (ZMQ_HAUSNUMERO + 54)
142
143 /* This function retrieves the errno as it is known to 0MQ library. The goal */
144 /* of this function is to make the code 100% portable, including where 0MQ */
145 /* compiled with certain CRT library (on Windows) is linked to an */
146 /* application that uses different CRT library. */
147 ZMQ_EXPORT int zmq_errno (void);
148
149 /* Resolves system errors and 0MQ errors to human-readable string. */
150 ZMQ_EXPORT const char *zmq_strerror (int errnum);
151
152 /******************************************************************************/
153 /* 0MQ infrastructure (a.k.a. context) initialisation & termination. */
154 /******************************************************************************/
155
156 /* New API */
157 /* Context options */
158 #define ZMQ_IO_THREADS 1
159 #define ZMQ_MAX_SOCKETS 2
160
161 /* Default for new contexts */
162 #define ZMQ_IO_THREADS_DFLT 1
163 #define ZMQ_MAX_SOCKETS_DFLT 1024
164
165 ZMQ_EXPORT void *zmq_ctx_new (void);
166 ZMQ_EXPORT int zmq_ctx_destroy (void *context);
167 ZMQ_EXPORT int zmq_ctx_set (void *context, int option, int optval);
168 ZMQ_EXPORT int zmq_ctx_get (void *context, int option);
169
170 /* Old (legacy) API */
171 ZMQ_EXPORT void *zmq_init (int io_threads);
172 ZMQ_EXPORT int zmq_term (void *context);
173
174
175 /******************************************************************************/
176 /* 0MQ message definition. */
177 /******************************************************************************/
178
179 typedef struct zmq_msg_t {unsigned char _ [32];} zmq_msg_t;
180
181 typedef void (zmq_free_fn) (void *data, void *hint);
182
183 ZMQ_EXPORT int zmq_msg_init (zmq_msg_t *msg);
184 ZMQ_EXPORT int zmq_msg_init_size (zmq_msg_t *msg, size_t size);
185 ZMQ_EXPORT int zmq_msg_init_data (zmq_msg_t *msg, void *data,
186 size_t size, zmq_free_fn *ffn, void *hint);
187 ZMQ_EXPORT int zmq_msg_send (zmq_msg_t *msg, void *s, int flags);
188 ZMQ_EXPORT int zmq_msg_recv (zmq_msg_t *msg, void *s, int flags);
189 ZMQ_EXPORT int zmq_msg_close (zmq_msg_t *msg);
190 ZMQ_EXPORT int zmq_msg_move (zmq_msg_t *dest, zmq_msg_t *src);
191 ZMQ_EXPORT int zmq_msg_copy (zmq_msg_t *dest, zmq_msg_t *src);
192 ZMQ_EXPORT void *zmq_msg_data (zmq_msg_t *msg);
193 ZMQ_EXPORT size_t zmq_msg_size (zmq_msg_t *msg);
194 ZMQ_EXPORT int zmq_msg_more (zmq_msg_t *msg);
195 ZMQ_EXPORT int zmq_msg_get (zmq_msg_t *msg, int option);
196 ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, int optval);
197
198
199 /******************************************************************************/
200 /* 0MQ socket definition. */
201 /******************************************************************************/
202
203 /* Socket types. */
204 #define ZMQ_PAIR 0
205 #define ZMQ_PUB 1
206 #define ZMQ_SUB 2
207 #define ZMQ_REQ 3
208 #define ZMQ_REP 4
209 #define ZMQ_DEALER 5
210 #define ZMQ_ROUTER 6
211 #define ZMQ_PULL 7
212 #define ZMQ_PUSH 8
213 #define ZMQ_XPUB 9
214 #define ZMQ_XSUB 10
215
216 /* Deprecated aliases */
217 #define ZMQ_XREQ ZMQ_DEALER
218 #define ZMQ_XREP ZMQ_ROUTER
219
220 /* Socket options. */
221 #define ZMQ_AFFINITY 4
222 #define ZMQ_IDENTITY 5
223 #define ZMQ_SUBSCRIBE 6
224 #define ZMQ_UNSUBSCRIBE 7
225 #define ZMQ_RATE 8
226 #define ZMQ_RECOVERY_IVL 9
227 #define ZMQ_SNDBUF 11
228 #define ZMQ_RCVBUF 12
229 #define ZMQ_RCVMORE 13
230 #define ZMQ_FD 14
231 #define ZMQ_EVENTS 15
232 #define ZMQ_TYPE 16
233 #define ZMQ_LINGER 17
234 #define ZMQ_RECONNECT_IVL 18
235 #define ZMQ_BACKLOG 19
236 #define ZMQ_RECONNECT_IVL_MAX 21
237 #define ZMQ_MAXMSGSIZE 22
238 #define ZMQ_SNDHWM 23
239 #define ZMQ_RCVHWM 24
240 #define ZMQ_MULTICAST_HOPS 25
241 #define ZMQ_RCVTIMEO 27
242 #define ZMQ_SNDTIMEO 28
243 #define ZMQ_IPV4ONLY 31
244 #define ZMQ_LAST_ENDPOINT 32
245 #define ZMQ_ROUTER_MANDATORY 33
246 #define ZMQ_TCP_KEEPALIVE 34
247 #define ZMQ_TCP_KEEPALIVE_CNT 35
248 #define ZMQ_TCP_KEEPALIVE_IDLE 36
249 #define ZMQ_TCP_KEEPALIVE_INTVL 37
250 #define ZMQ_TCP_ACCEPT_FILTER 38
251 #define ZMQ_DELAY_ATTACH_ON_CONNECT 39
252 #define ZMQ_XPUB_VERBOSE 40
253
254
255 /* Message options */
256 #define ZMQ_MORE 1
257
258 /* Send/recv options. */
259 #define ZMQ_DONTWAIT 1
260 #define ZMQ_SNDMORE 2
261
262 /* Deprecated aliases */
263 #define ZMQ_NOBLOCK ZMQ_DONTWAIT
264 #define ZMQ_FAIL_UNROUTABLE ZMQ_ROUTER_MANDATORY
265 #define ZMQ_ROUTER_BEHAVIOR ZMQ_ROUTER_MANDATORY
266
267 /******************************************************************************/
268 /* 0MQ socket events and monitoring */
269 /******************************************************************************/
270
271 /* Socket transport events (tcp and ipc only) */
272 #define ZMQ_EVENT_CONNECTED 1
273 #define ZMQ_EVENT_CONNECT_DELAYED 2
274 #define ZMQ_EVENT_CONNECT_RETRIED 4
275
276 #define ZMQ_EVENT_LISTENING 8
277 #define ZMQ_EVENT_BIND_FAILED 16
278
279 #define ZMQ_EVENT_ACCEPTED 32
280 #define ZMQ_EVENT_ACCEPT_FAILED 64
281
282 #define ZMQ_EVENT_CLOSED 128
283 #define ZMQ_EVENT_CLOSE_FAILED 256
284 #define ZMQ_EVENT_DISCONNECTED 512
285
286 #define ZMQ_EVENT_ALL ( ZMQ_EVENT_CONNECTED | ZMQ_EVENT_CONNECT_DELAYED | \
287 ZMQ_EVENT_CONNECT_RETRIED | ZMQ_EVENT_LISTENING | \
288 ZMQ_EVENT_BIND_FAILED | ZMQ_EVENT_ACCEPTED | \
289 ZMQ_EVENT_ACCEPT_FAILED | ZMQ_EVENT_CLOSED | \
290 ZMQ_EVENT_CLOSE_FAILED | ZMQ_EVENT_DISCONNECTED )
291
292 /* Socket event data (union member per event) */
293 typedef struct {
294 int event;
295 union {
296 struct {
297 char *addr;
298 int fd;
299 } connected;
300 struct {
301 char *addr;
302 int err;
303 } connect_delayed;
304 struct {
305 char *addr;
306 int interval;
307 } connect_retried;
308 struct {
309 char *addr;
310 int fd;
311 } listening;
312 struct {
313 char *addr;
314 int err;
315 } bind_failed;
316 struct {
317 char *addr;
318 int fd;
319 } accepted;
320 struct {
321 char *addr;
322 int err;
323 } accept_failed;
324 struct {
325 char *addr;
326 int fd;
327 } closed;
328 struct {
329 char *addr;
330 int err;
331 } close_failed;
332 struct {
333 char *addr;
334 int fd;
335 } disconnected;
336 } data;
337 } zmq_event_t;
338
339 ZMQ_EXPORT void *zmq_socket (void *, int type);
340 ZMQ_EXPORT int zmq_close (void *s);
341 ZMQ_EXPORT int zmq_setsockopt (void *s, int option, const void *optval,
342 size_t optvallen);
343 ZMQ_EXPORT int zmq_getsockopt (void *s, int option, void *optval,
344 size_t *optvallen);
345 ZMQ_EXPORT int zmq_bind (void *s, const char *addr);
346 ZMQ_EXPORT int zmq_connect (void *s, const char *addr);
347 ZMQ_EXPORT int zmq_unbind (void *s, const char *addr);
348 ZMQ_EXPORT int zmq_disconnect (void *s, const char *addr);
349 ZMQ_EXPORT int zmq_send (void *s, const void *buf, size_t len, int flags);
350 ZMQ_EXPORT int zmq_recv (void *s, void *buf, size_t len, int flags);
351 ZMQ_EXPORT int zmq_socket_monitor (void *s, const char *addr, int events);
352
353 ZMQ_EXPORT int zmq_sendmsg (void *s, zmq_msg_t *msg, int flags);
354 ZMQ_EXPORT int zmq_recvmsg (void *s, zmq_msg_t *msg, int flags);
355
356 /* Experimental */
357 struct iovec;
358
359 ZMQ_EXPORT int zmq_sendiov (void *s, struct iovec *iov, size_t count, int flags);
360 ZMQ_EXPORT int zmq_recviov (void *s, struct iovec *iov, size_t *count, int flags);
361
362 /******************************************************************************/
363 /* I/O multiplexing. */
364 /******************************************************************************/
365
366 #define ZMQ_POLLIN 1
367 #define ZMQ_POLLOUT 2
368 #define ZMQ_POLLERR 4
369
370 typedef struct
371 {
372 void *socket;
373 #if defined _WIN32
374 SOCKET fd;
375 #else
376 int fd;
377 #endif
378 short events;
379 short revents;
380 } zmq_pollitem_t;
381
382 ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout);
383
384 /* Built-in message proxy (3-way) */
385
386 ZMQ_EXPORT int zmq_proxy (void *frontend, void *backend, void *capture);
387
388 /* Deprecated aliases */
389 #define ZMQ_STREAMER 1
390 #define ZMQ_FORWARDER 2
391 #define ZMQ_QUEUE 3
392 /* Deprecated method */
393 ZMQ_EXPORT int zmq_device (int type, void *frontend, void *backend);
394
395 #undef ZMQ_EXPORT
396
397 #ifdef __cplusplus
398 }
399 #endif
400
401 #endif
402

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23