summaryrefslogtreecommitdiff
path: root/bindings/c
diff options
context:
space:
mode:
authormalosek <malosek@fastmq.com>2009-10-05 10:22:31 +0200
committermalosek <malosek@fastmq.com>2009-10-05 10:22:31 +0200
commitd57ee0984ac3f8712063a7f83d7200be25ca5513 (patch)
treea956443e70c48ebd21242c11cc015db61c53c682 /bindings/c
parentff65e26ce7567ea6a907e566f8530f4988231d68 (diff)
parent4efe2366d7394e8969fc9aa64c50be6842d8455f (diff)
Merge branch 'master' of git@github.com:sustrik/zeromq2
Diffstat (limited to 'bindings/c')
-rw-r--r--bindings/c/zmq.h49
1 files changed, 47 insertions, 2 deletions
diff --git a/bindings/c/zmq.h b/bindings/c/zmq.h
index f42f7f9..40750ec 100644
--- a/bindings/c/zmq.h
+++ b/bindings/c/zmq.h
@@ -51,6 +51,18 @@ extern "C" {
#ifndef EPROTONOSUPPORT
#define EPROTONOSUPPORT (ZMQ_HAUSNUMERO + 2)
#endif
+#ifndef ENOBUFS
+#define ENOBUFS (ZMQ_HAUSNUMERO + 3)
+#endif
+#ifndef ENETDOWN
+#define ENETDOWN (ZMQ_HAUSNUMERO + 4)
+#endif
+#ifndef EADDRINUSE
+#define EADDRINUSE (ZMQ_HAUSNUMERO + 5)
+#endif
+#ifndef EADDRNOTAVAIL
+#define EADDRNOTAVAIL (ZMQ_HAUSNUMERO + 6)
+#endif
// Native 0MQ error codes.
#define EMTHREAD (ZMQ_HAUSNUMERO + 50)
@@ -344,8 +356,8 @@ ZMQ_EXPORT int zmq_send (void *s, zmq_msg_t *msg, int flags);
// EFSM - function cannot be called at the moment.
ZMQ_EXPORT int zmq_flush (void *s);
-// Send a message from the socket 's'. 'flags' argument can be combination
-// of the flags described above.
+// Receive a message from the socket 's'. 'flags' argument can be combination
+// of the flags described above with the exception of ZMQ_NOFLUSH.
//
// Errors: EAGAIN - message cannot be received at the moment (applies only to
// non-blocking receive).
@@ -354,6 +366,39 @@ ZMQ_EXPORT int zmq_flush (void *s);
ZMQ_EXPORT int zmq_recv (void *s, zmq_msg_t *msg, int flags);
////////////////////////////////////////////////////////////////////////////////
+// I/O multiplexing.
+////////////////////////////////////////////////////////////////////////////////
+
+#define ZMQ_POLLIN 1
+#define ZMQ_POLLOUT 2
+
+// 'socket' is a 0MQ socket we want to poll on. If set to NULL, native file
+// descriptor (socket) 'fd' will be used instead. 'events' defines event we
+// are going to poll on - combination of ZMQ_POLLIN and ZMQ_POLLOUT. Error
+// event does not exist for portability reasons. Errors from native sockets
+// are reported as ZMQ_POLLIN. It's client's responsibilty to identify the
+// error afterwards. 'revents' field is filled in after function returns. It's
+// a combination of ZMQ_POLLIN and/or ZMQ_POLLOUT depending on the state of the
+// socket.
+typedef struct
+{
+ void *socket;
+ int fd;
+ short events;
+ short revents;
+} zmq_pollitem_t;
+
+// Polls for the items specified by 'items'. Number of items in the array is
+// determined by 'nitems' argument. Returns number of items signaled, -1
+// in the case of error.
+//
+// Errors: EFAULT - there's a 0MQ socket in the pollset belonging to
+// a different thread.
+// ENOTSUP - 0MQ context was initialised without ZMQ_POLL flag.
+// I/O multiplexing is disabled.
+ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items, int nitems);
+
+////////////////////////////////////////////////////////////////////////////////
// Helper functions.
////////////////////////////////////////////////////////////////////////////////