Commits

Brandon Rhodes committed 8e219c6

Upgraded code to ØMQ and PyZMQ 2.1.7.

Comments (0)

Files changed (56)

 ^build$
 ^dist$
 \.egg-info$
-^pyzmq-2.1.1$
-^util-linux-2.19$
+^pyzmq-[\d.]+$
+^util-linux-[\d.]+$
 ^tmp$
-^zeromq-2.1.4$
+^zeromq-[\d.]+$
 so that you do not have to install ØMQ separately on your system.
 This version combines:
 
-* ØMQ 2.1.4 — http://www.zeromq.org/
-* PyZMQ 2.1.1 — http://pypi.python.org/pypi/pyzmq/
+* ØMQ 2.1.7 — http://www.zeromq.org/
+* PyZMQ 2.1.7 — http://pypi.python.org/pypi/pyzmq/
 
 On Linux and MacOS systems (but not on Windows or FreeBSD),
 the ``libuuid`` library code is also compiled in:
 Changelog
 ---------
 
+| 2011-05-22 — 2.1.7 — ØMQ and PyZMQ 2.1.7.
 | 2011-04-02 — 2.1.4 — ØMQ 2.1.4; PyZMQ 2.1.1; util-linux-ng 2.19.
 | 2010-11-17 — 2.0.10 — ØMQ 2.0.10; FreeBSD support.
 | 2010-09-27 — 2.0.8 — Mac OS X support.
 cd $(dirname "$0")
 
 UTIL=util-linux-2.19
-ZEROMQ=zeromq-2.1.4
-PYZMQ=pyzmq-2.1.1
+ZEROMQ=zeromq-2.1.7
+PYZMQ=pyzmq-2.1.7
 
 # Download source distributions, or make sure they are up to date.
 
     cd tmp
     curl -O "http://www.kernel.org/pub/linux/utils/util-linux-ng/v2.19/$UTIL.tar.gz"
     curl -O "http://download.zeromq.org/$ZEROMQ.tar.gz"
-    curl -O "http://pypi.python.org/packages/source/p/pyzmq/pyzmq-2.1.1.tar.gz"
+    curl -O "http://pypi.python.org/packages/source/p/pyzmq/$PYZMQ.tar.gz"
     cd ..
 fi
 
         //  of I/O thread pool to create.
         ctx_t (uint32_t io_threads_);
 
+        //  Returns false if object is not a context.
+        bool check_tag ();
+
         //  This function is called when user invokes zmq_term. If there are
         //  no more sockets open it'll cause all the infrastructure to be shut
         //  down. If there are open sockets still, the deallocation happens
 
         ~ctx_t ();
 
+        //  Used to check whether the object is a context.
+        uint32_t tag;
+
         //  Sockets belonging to this context. We need the list so that
         //  we can notify the sockets when zmq_term() is called. The sockets
         //  will return ETERM then.
         //  Put the message to all active pipes.
         void distribute (zmq_msg_t *msg_, int flags_);
 
-        //  Plug in all the delayed pipes.
-        void clear_new_pipes ();
-
         //  List of outbound pipes.
         typedef array_t <class writer_t> pipes_t;
         pipes_t pipes;
 
-        //  List of new pipes that were not yet inserted into 'pipes' list.
-        //  These pipes are moves to 'pipes' list once the current multipart
-        //  message is fully sent. This way we avoid sending incomplete messages
-        //  to peers.
-        typedef std::vector <class writer_t*> new_pipes_t;
-        new_pipes_t new_pipes;
+        //  Number of active pipes. All the active pipes are located at the
+        //  beginning of the pipes array. These are the pipes the messages
+        //  can be sent to at the moment.
+        pipes_t::size_type active;
 
-        //  Number of active pipes. All the active pipes are located at the
-        //  beginning of the pipes array.
-        pipes_t::size_type active;
+        //  Number of pipes eligible for sending messages to. This includes all
+        //  the active pipes plus all the pipes that we can in theory send
+        //  messages to (the HWM is not yet reached), but sending a message
+        //  to them would result in partial message being delivered, ie. message
+        //  with initial parts missing.
+        pipes_t::size_type eligible;
 
         //  True if last we are in the middle of a multipart message.
         bool more;
 namespace zmq
 {
     const char *wsa_error ();
+    const char *wsa_error_no (int no_);
     void win_error (char *buffer_, size_t buffer_size_);
     void wsa_error_to_errno (); 
 }
         }\
     } while (false)
 
+//  Provides convenient way to assert on WSA-style errors on Windows.
+#define wsa_assert_no(no) \
+    do {\
+        const char *errstr = zmq::wsa_error_no (no);\
+        if (errstr != NULL) {\
+            fprintf (stderr, "Assertion failed: %s (%s:%d)\n", errstr, \
+                __FILE__, __LINE__);\
+            abort ();\
+        }\
+    } while (false)
+
 // Provides convenient way to check GetLastError-style errors on Windows.
 #define win_assert(x) \
     do {\

include/socket_base.hpp

 
     public:
 
+        //  Returns false if object is not a socket.
+        bool check_tag ();
+
         //  Create a socket of a specified type.
         static socket_base_t *create (int type_, class ctx_t *parent_,
             uint32_t tid_);
 
     private:
 
+        //  Used to check whether the object is a socket.
+        uint32_t tag;
+
         //  If true, associated context was already terminated.
         bool ctx_terminated;
 
             const blob_t &peer_identity_);
         int xsend (zmq_msg_t *msg_, int flags_);
         int xrecv (zmq_msg_t *msg_, int flags_);
+        int rollback ();
         bool xhas_in ();
         bool xhas_out ();
 
 /*  Version macros for compile-time API version detection                     */
 #define ZMQ_VERSION_MAJOR 2
 #define ZMQ_VERSION_MINOR 1
-#define ZMQ_VERSION_PATCH 4
+#define ZMQ_VERSION_PATCH 7
 
 #define ZMQ_MAKE_VERSION(major, minor, patch) \
     ((major) * 10000 + (minor) * 100 + (patch))
 #ifndef EINPROGRESS
 #define EINPROGRESS (ZMQ_HAUSNUMERO + 8)
 #endif
+#ifndef ENOTSOCK
+#define ENOTSOCK (ZMQ_HAUSNUMERO + 9)
+#endif
 
 /*  Native 0MQ error codes.                                                   */
 #define EFSM (ZMQ_HAUSNUMERO + 51)
 /*  allows us to pack the stucture tigher and thus improve performance.       */
 #define ZMQ_MSG_MORE 1
 #define ZMQ_MSG_SHARED 128
+#define ZMQ_MSG_MASK 129 /* Merges all the flags */
 
 /*  A message. Note that 'content' is not a pointer to the raw data.          */
 /*  Rather it is pointer to zmq::msg_content_t structure                      */
         {
             return ptr;
         }
-        
+
     private:
 
         void *ptr;

include/zmq_compat.h

 #define pyzmq_int64_t int64_t
 #endif
 
+
 // version compatibility for constants:
 #include "zmq.h"
+
 #define _missing (PyErr_SetString(PyExc_NotImplementedError, \
-                "Constant not available in current zeromq."), -1)
+                "Not available in current zeromq."), -1)
+
 // 2.1.0
+
 #ifndef ZMQ_FD
     #define ZMQ_FD (-1)
+        
 #endif
+
 #ifndef ZMQ_EVENTS
+                    
     #define ZMQ_EVENTS (-1)
 #endif
 #ifndef ZMQ_TYPE
 #ifndef ZMQ_RECONNECT_IVL_MAX
     #define ZMQ_RECONNECT_IVL_MAX (-1)
 #endif
+// 2.1.4
+#ifndef ZMQ_DEALER
+    #define ZMQ_DEALER (-1)
+#endif
+#ifndef ZMQ_ROUTER
+    #define ZMQ_ROUTER (-1)
+#endif
+
+// new in 3.0.0
+#ifndef ENOTSOCK
+    #define ENOTSOCK (-1)
+#endif
+
+#ifndef ZMQ_MAXMSGSIZE
+    #define ZMQ_MAXMSGSIZE (-1)
+#endif
+#ifndef ZMQ_SNDHWM
+    #define ZMQ_SNDHWM (-1)
+#endif
+#ifndef ZMQ_RCVHWM
+    #define ZMQ_RCVHWM (-1)
+#endif
+
+#ifndef ZMQ_DONTWAIT
+    #define ZMQ_DONTWAIT (-1)
+#endif
+
+
+// removed in 3.0.0
+#ifndef ZMQ_MAX_VSM_SIZE
+    #define ZMQ_MAX_VSM_SIZE (-1)
+#endif
+#ifndef ZMQ_DELIMITER
+    #define ZMQ_DELIMITER (-1)
+#endif
+#ifndef ZMQ_MSG_MORE
+    #define ZMQ_MSG_MORE (-1)
+#endif
+#ifndef ZMQ_MSG_SHARED
+    #define ZMQ_MSG_SHARED (-1)
+#endif
+
+#ifndef ZMQ_UPSTREAM
+    #define ZMQ_UPSTREAM (-1)
+#endif
+#ifndef ZMQ_DOWNSTREAM
+    #define ZMQ_DOWNSTREAM (-1)
+#endif
+
+#ifndef ZMQ_HWM
+    #define ZMQ_HWM (-1)
+#endif
+#ifndef ZMQ_SWAP
+    #define ZMQ_SWAP (-1)
+#endif
+#ifndef ZMQ_MCAST_LOOP
+    #define ZMQ_MCAST_LOOP (-1)
+#endif
+#ifndef ZMQ_RECOVERY_IVL_MSEC
+    #define ZMQ_RECOVERY_IVL_MSEC (-1)
+#endif
+
+#ifndef ZMQ_NOBLOCK
+    #define ZMQ_NOBLOCK (-1)
+#endif
+
+// keep the device constants, because we will roll our own zmq_device()
+#ifndef ZMQ_STREAMER
+    #define ZMQ_STREAMER 1
+#endif
+#ifndef ZMQ_FORWARDER
+    #define ZMQ_FORWARDER 2
+#endif
+#ifndef ZMQ_QUEUE
+    #define ZMQ_QUEUE 3
+#endif
+
+// use unambiguous aliases for zmq_send/recv functions
+#if ZMQ_VERSION_MAJOR >= 3
+    #define zmq_sendbuf zmq_send
+    #define zmq_recvbuf zmq_recv
+    #define zmq_device(type,in,out) _missing
+#else
+    #define zmq_sendmsg zmq_send
+    #define zmq_recvmsg zmq_recv
+    #define zmq_sendbuf (void *s, const void *buf, size_t len, int flags) _missing
+    #define zmq_recvbuf (void *s, void *buf, size_t len, int flags) _missing
+#endif

include_freebsd/platform.hpp

 #define PACKAGE_NAME "zeromq"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "zeromq 2.1.4"
+#define PACKAGE_STRING "zeromq 2.1.7"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "zeromq"
 #define PACKAGE_URL ""
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "2.1.4"
+#define PACKAGE_VERSION "2.1.7"
 
 /* Define as the return type of signal handlers (`int' or `void'). */
 #define RETSIGTYPE void
 #define TIME_WITH_SYS_TIME 1
 
 /* Version number of package */
-#define VERSION "2.1.4"
+#define VERSION "2.1.7"
 
 /* Force to use mutexes */
 /* #undef ZMQ_FORCE_MUTEXES */

include_linux/platform.hpp

 #define PACKAGE_NAME "zeromq"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "zeromq 2.1.4"
+#define PACKAGE_STRING "zeromq 2.1.7"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "zeromq"
 #define PACKAGE_URL ""
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "2.1.4"
+#define PACKAGE_VERSION "2.1.7"
 
 /* Define as the return type of signal handlers (`int' or `void'). */
 #define RETSIGTYPE void
 #define TIME_WITH_SYS_TIME 1
 
 /* Version number of package */
-#define VERSION "2.1.4"
+#define VERSION "2.1.7"
 
 /* Force to use mutexes */
 /* #undef ZMQ_FORCE_MUTEXES */

include_macosx/platform.hpp

 #define PACKAGE_NAME "zeromq"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "zeromq 2.1.4"
+#define PACKAGE_STRING "zeromq 2.1.7"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "zeromq"
 #define PACKAGE_URL ""
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "2.1.4"
+#define PACKAGE_VERSION "2.1.7"
 
 /* Define as the return type of signal handlers (`int' or `void'). */
 #define RETSIGTYPE void
 #define TIME_WITH_SYS_TIME 1
 
 /* Version number of package */
-#define VERSION "2.1.4"
+#define VERSION "2.1.7"
 
 /* Force to use mutexes */
 /* #undef ZMQ_FORCE_MUTEXES */
---- zmq/__init__.py.orig	2011-04-01 18:54:36.000000000 -0400
-+++ zmq/__init__.py	2011-04-01 18:54:40.000000000 -0400
-@@ -23,6 +23,16 @@
- # Imports
- #-----------------------------------------------------------------------------
+--- zmq/__init__.py.orig	2011-05-12 02:25:07.000000000 -0400
++++ zmq/__init__.py	2011-05-22 22:57:24.000000000 -0400
+@@ -31,6 +31,12 @@
+     if os.path.exists(libzmq):
+         ctypes.cdll.LoadLibrary(libzmq)
+     del here, libzmq, ctypes, os
++else:
++    import ctypes
++    import os
++    p = os.path.join(os.path.dirname(__file__), "_zeromq.so")
++    _zeromq = ctypes.CDLL(p, mode=ctypes.RTLD_GLOBAL)
++    del ctypes, os, p
  
-+# First, use ctypes to load the shared library.
-+
-+import ctypes
-+import os
-+p = os.path.join(os.path.dirname(__file__), "_zeromq.so")
-+_zeromq = ctypes.CDLL(p, mode=ctypes.RTLD_GLOBAL)
-+del ctypes, os, p
-+
-+# Now we can safely proceed to load the Python extensions.
-+
  from zmq.utils import initthreads # initialize threads
  initthreads.init_threads()
- 
     description = u'zmq package that compiles its own ØMQ / 0MQ / ZeroMQ'
 
 setup(name='pyzmq-static',
-      version='2.1.4',
+      version='2.1.7',
       description=description,
       long_description=long_description,
       author='Brandon Craig Rhodes',
 #endif
 
 zmq::ctx_t::ctx_t (uint32_t io_threads_) :
+    tag (0xbadcafe0),
     terminating (false)
 {
     int rc;
     zmq_assert (rc == 0);
 }
 
+bool zmq::ctx_t::check_tag ()
+{
+    return tag == 0xbadcafe0;
+}
+
 zmq::ctx_t::~ctx_t ()
 {
     //  Check that there are no remaining sockets.
     //  needed as mailboxes themselves were deallocated with their
     //  corresponding io_thread/socket objects.
     free (slots);
+
+    //  Remove the tag, so that the object is considered dead.
+    tag = 0xdeadbeef;
 }
 
 int zmq::ctx_t::terminate ()
 bool zmq::decoder_t::flags_ready ()
 {
     //  Store the flags from the wire into the message structure.
-    in_progress.flags = tmpbuf [0];
+    in_progress.flags = tmpbuf [0] | ~ZMQ_MSG_MASK;
 
     next_step (zmq_msg_data (&in_progress), zmq_msg_size (&in_progress),
         &decoder_t::message_ready);
-    
+
     return true;
 }
 
 #include "err.hpp"
 #include "own.hpp"
 #include "msg_content.hpp"
+#include "likely.hpp"
 
 zmq::dist_t::dist_t (own_t *sink_) :
     active (0),
+    eligible (0),
     more (false),
     sink (sink_),
     terminating (false)
 
 void zmq::dist_t::attach (writer_t *pipe_)
 {
-    //  If we are in the middle of sending a message, let's postpone plugging
-    //  in the pipe.
-    if (!terminating && more) {
-        new_pipes.push_back (pipe_);
-        return;
+    pipe_->set_event_sink (this);
+
+    //  If we are in the middle of sending a message, we'll add new pipe
+    //  into the list of eligible pipes. Otherwise we add it to the list
+    //  of active pipes.
+    if (more) {
+        pipes.push_back (pipe_);
+        pipes.swap (eligible, pipes.size () - 1);
+        eligible++;
+    }
+    else {
+        pipes.push_back (pipe_);
+        pipes.swap (active, pipes.size () - 1);
+        active++;
+        eligible++;
     }
 
-    pipe_->set_event_sink (this);
-
-    pipes.push_back (pipe_);
-    pipes.swap (active, pipes.size () - 1);
-    active++;
-
-    if (terminating) {
+    if (unlikely (terminating)) {
         sink->register_term_acks (1);
         pipe_->terminate ();
     }
 
 void zmq::dist_t::terminated (writer_t *pipe_)
 {
-    //  Remove the pipe from the list; adjust number of active pipes
-    //  accordingly.
+    //  Remove the pipe from the list; adjust number of active and/or
+    //  eligible pipes accordingly.
     if (pipes.index (pipe_) < active)
         active--;
+    if (pipes.index (pipe_) < eligible)
+        eligible--;
     pipes.erase (pipe_);
 
-    if (terminating)
+    if (unlikely (terminating))
         sink->unregister_term_ack ();
 }
 
 void zmq::dist_t::activated (writer_t *pipe_)
 {
-    //  Move the pipe to the list of active pipes.
-    pipes.swap (pipes.index (pipe_), active);
-    active++;
+    //  Move the pipe from passive to eligible state.
+    pipes.swap (pipes.index (pipe_), eligible);
+    eligible++;
+
+    //  If there's no message being sent at the moment, move it to
+    //  the active state.
+    if (!more) {
+        pipes.swap (eligible - 1, active);
+        active++;
+    }
 }
 
 int zmq::dist_t::send (zmq_msg_t *msg_, int flags_)
     //  Push the message to active pipes.
     distribute (msg_, flags_);
 
-    //  If mutlipart message is fully sent, activate new pipes.
-    if (more && !msg_more)
-        clear_new_pipes ();
+    //  If multipart message is fully sent, activate all the eligible pipes.
+    if (!msg_more)
+        active = eligible;
 
     more = msg_more;
 
 bool zmq::dist_t::write (class writer_t *pipe_, zmq_msg_t *msg_)
 {
     if (!pipe_->write (msg_)) {
+        pipes.swap (pipes.index (pipe_), active - 1);
         active--;
-        pipes.swap (pipes.index (pipe_), active);
+        pipes.swap (active, eligible - 1);
+        eligible--;
         return false;
     }
     if (!(msg_->flags & ZMQ_MSG_MORE))
         pipe_->flush ();
     return true;
 }
-
-void zmq::dist_t::clear_new_pipes ()
-{
-    for (new_pipes_t::iterator it = new_pipes.begin (); it != new_pipes.end ();
-          ++it) {
-        (*it)->set_event_sink (this);
-        pipes.push_back (*it);
-        pipes.swap (active, pipes.size () - 1);
-        active++;
-    }
-    new_pipes.clear ();
-}
-
 
 const char *zmq::wsa_error()
 {
-    int errcode = WSAGetLastError ();
+    int no = WSAGetLastError ();
     //  TODO: This is not a generic way to handle this...
-    if (errcode == WSAEWOULDBLOCK)
+    if (no == WSAEWOULDBLOCK)
         return NULL;
 
+    return wsa_error_no (no);
+}
+
+const char *zmq::wsa_error_no (int no_)
+{
     //  TODO:  It seems that list of Windows socket errors is longer than this.
     //         Investigate whether there's a way to convert it into the string
     //         automatically (wsaError->HRESULT->string?).
     return
-        (errcode == WSABASEERR) ?
+        (no_ == WSABASEERR) ?
             "No Error" : 
-        (errcode == WSAEINTR) ?
+        (no_ == WSAEINTR) ?
             "Interrupted system call" : 
-        (errcode == WSAEBADF) ?
+        (no_ == WSAEBADF) ?
             "Bad file number" : 
-        (errcode == WSAEACCES) ?
+        (no_ == WSAEACCES) ?
             "Permission denied" : 
-        (errcode == WSAEFAULT) ?
+        (no_ == WSAEFAULT) ?
             "Bad address" : 
-        (errcode == WSAEINVAL) ?
+        (no_ == WSAEINVAL) ?
             "Invalid argument" : 
-        (errcode == WSAEMFILE) ?
+        (no_ == WSAEMFILE) ?
             "Too many open files" : 
-        (errcode == WSAEWOULDBLOCK) ?
+        (no_ == WSAEWOULDBLOCK) ?
             "Operation would block" : 
-        (errcode == WSAEINPROGRESS) ?
+        (no_ == WSAEINPROGRESS) ?
             "Operation now in progress" : 
-        (errcode == WSAEALREADY) ?
+        (no_ == WSAEALREADY) ?
             "Operation already in progress" : 
-        (errcode == WSAENOTSOCK) ?
+        (no_ == WSAENOTSOCK) ?
             "Socket operation on non-socket" : 
-        (errcode == WSAEDESTADDRREQ) ?
+        (no_ == WSAEDESTADDRREQ) ?
             "Destination address required" : 
-        (errcode == WSAEMSGSIZE) ?
+        (no_ == WSAEMSGSIZE) ?
             "Message too long" : 
-        (errcode == WSAEPROTOTYPE) ?
+        (no_ == WSAEPROTOTYPE) ?
             "Protocol wrong type for socket" : 
-        (errcode == WSAENOPROTOOPT) ?
+        (no_ == WSAENOPROTOOPT) ?
             "Bad protocol option" : 
-        (errcode == WSAEPROTONOSUPPORT) ?
+        (no_ == WSAEPROTONOSUPPORT) ?
             "Protocol not supported" : 
-        (errcode == WSAESOCKTNOSUPPORT) ?
+        (no_ == WSAESOCKTNOSUPPORT) ?
             "Socket type not supported" : 
-        (errcode == WSAEOPNOTSUPP) ?
+        (no_ == WSAEOPNOTSUPP) ?
             "Operation not supported on socket" : 
-        (errcode == WSAEPFNOSUPPORT) ?
+        (no_ == WSAEPFNOSUPPORT) ?
             "Protocol family not supported" : 
-        (errcode == WSAEAFNOSUPPORT) ?
+        (no_ == WSAEAFNOSUPPORT) ?
             "Address family not supported by protocol family" : 
-        (errcode == WSAEADDRINUSE) ?
+        (no_ == WSAEADDRINUSE) ?
             "Address already in use" : 
-        (errcode == WSAEADDRNOTAVAIL) ?
+        (no_ == WSAEADDRNOTAVAIL) ?
             "Can't assign requested address" : 
-        (errcode == WSAENETDOWN) ?
+        (no_ == WSAENETDOWN) ?
             "Network is down" : 
-        (errcode == WSAENETUNREACH) ?
+        (no_ == WSAENETUNREACH) ?
             "Network is unreachable" : 
-        (errcode == WSAENETRESET) ?
+        (no_ == WSAENETRESET) ?
             "Net dropped connection or reset" : 
-        (errcode == WSAECONNABORTED) ?
+        (no_ == WSAECONNABORTED) ?
             "Software caused connection abort" : 
-        (errcode == WSAECONNRESET) ?
+        (no_ == WSAECONNRESET) ?
             "Connection reset by peer" : 
-        (errcode == WSAENOBUFS) ?
+        (no_ == WSAENOBUFS) ?
             "No buffer space available" : 
-        (errcode == WSAEISCONN) ?
+        (no_ == WSAEISCONN) ?
             "Socket is already connected" : 
-        (errcode == WSAENOTCONN) ?
+        (no_ == WSAENOTCONN) ?
             "Socket is not connected" : 
-        (errcode == WSAESHUTDOWN) ?
+        (no_ == WSAESHUTDOWN) ?
             "Can't send after socket shutdown" : 
-        (errcode == WSAETOOMANYREFS) ?
+        (no_ == WSAETOOMANYREFS) ?
             "Too many references can't splice" : 
-        (errcode == WSAETIMEDOUT) ?
+        (no_ == WSAETIMEDOUT) ?
             "Connection timed out" : 
-        (errcode == WSAECONNREFUSED) ?
+        (no_ == WSAECONNREFUSED) ?
             "Connection refused" : 
-        (errcode == WSAELOOP) ?
+        (no_ == WSAELOOP) ?
             "Too many levels of symbolic links" : 
-        (errcode == WSAENAMETOOLONG) ?
+        (no_ == WSAENAMETOOLONG) ?
             "File name too long" : 
-        (errcode == WSAEHOSTDOWN) ?
+        (no_ == WSAEHOSTDOWN) ?
             "Host is down" : 
-        (errcode == WSAEHOSTUNREACH) ?
+        (no_ == WSAEHOSTUNREACH) ?
             "No Route to Host" : 
-        (errcode == WSAENOTEMPTY) ?
+        (no_ == WSAENOTEMPTY) ?
             "Directory not empty" : 
-        (errcode == WSAEPROCLIM) ?
+        (no_ == WSAEPROCLIM) ?
             "Too many processes" : 
-        (errcode == WSAEUSERS) ?
+        (no_ == WSAEUSERS) ?
             "Too many users" : 
-        (errcode == WSAEDQUOT) ?
+        (no_ == WSAEDQUOT) ?
             "Disc Quota Exceeded" : 
-        (errcode == WSAESTALE) ?
+        (no_ == WSAESTALE) ?
             "Stale NFS file handle" : 
-        (errcode == WSAEREMOTE) ?
+        (no_ == WSAEREMOTE) ?
             "Too many levels of remote in path" : 
-        (errcode == WSASYSNOTREADY) ?
+        (no_ == WSASYSNOTREADY) ?
             "Network SubSystem is unavailable" : 
-        (errcode == WSAVERNOTSUPPORTED) ?
+        (no_ == WSAVERNOTSUPPORTED) ?
             "WINSOCK DLL Version out of range" : 
-        (errcode == WSANOTINITIALISED) ?
+        (no_ == WSANOTINITIALISED) ?
             "Successful WSASTARTUP not yet performed" : 
-        (errcode == WSAHOST_NOT_FOUND) ?
+        (no_ == WSAHOST_NOT_FOUND) ?
             "Host not found" : 
-        (errcode == WSATRY_AGAIN) ?
+        (no_ == WSATRY_AGAIN) ?
             "Non-Authoritative Host not found" : 
-        (errcode == WSANO_RECOVERY) ?
+        (no_ == WSANO_RECOVERY) ?
             "Non-Recoverable errors: FORMERR REFUSED NOTIMP" : 
-        (errcode == WSANO_DATA) ?
+        (no_ == WSANO_DATA) ?
             "Valid name no data record of requested" :
         "error not defined"; 
 }
+
 void zmq::win_error (char *buffer_, size_t buffer_size_)
 {
     DWORD errcode = GetLastError ();
 
 void zmq::fq_t::terminated (reader_t *pipe_)
 {
-    //  TODO: This is a problem with session-initiated termination. It breaks
-    //  message atomicity. However, for socket initiated termination it's
-    //  just fine.
-    zmq_assert (!more || pipes [current] != pipe_);
+    //  Make sure that we are not closing current pipe while
+    //  message is half-read.
+    zmq_assert (terminating || (!more || pipes [current] != pipe_));
 
     //  Remove the pipe from the list; adjust number of active pipes
     //  accordingly.
             int rc = xrep_t::xrecv (msg_, flags_);
             if (rc != 0)
                 return rc;
-            zmq_assert (msg_->flags & ZMQ_MSG_MORE);
 
-            //  Empty message part delimits the traceback stack.
-            bottom = (zmq_msg_size (msg_) == 0);
+            if ((msg_->flags & ZMQ_MSG_MORE)) {
+                //  Empty message part delimits the traceback stack.
+                bottom = (zmq_msg_size (msg_) == 0);
 
-            //  Push it to the reply pipe.
-            rc = xrep_t::xsend (msg_, flags_);
-            zmq_assert (rc == 0);
+                //  Push it to the reply pipe.
+                rc = xrep_t::xsend (msg_, flags_);
+                zmq_assert (rc == 0);
+            }
+            else {
+                //  If the traceback stack is malformed, discard anything
+                //  already sent to pipe (we're at end of invalid message).
+                rc = xrep_t::rollback ();
+                zmq_assert (rc == 0);
+            }
         }
 
         request_begins = false;
         zmq_msg_t prefix;
         int rc = zmq_msg_init (&prefix);
         zmq_assert (rc == 0);
-        prefix.flags = ZMQ_MSG_MORE;
+        prefix.flags |= ZMQ_MSG_MORE;
         rc = xreq_t::xsend (&prefix, flags_);
         if (rc != 0)
             return rc;

src/socket_base.cpp

 #include "xpub.hpp"
 #include "xsub.hpp"
 
+bool zmq::socket_base_t::check_tag ()
+{
+    return tag == 0xbaddecaf;
+}
+
 zmq::socket_base_t *zmq::socket_base_t::create (int type_, class ctx_t *parent_,
     uint32_t tid_)
 {
         break;
     case ZMQ_XREP:
         s = new (std::nothrow) xrep_t (parent_, tid_);
-        break;     
+        break;
     case ZMQ_PULL:
         s = new (std::nothrow) pull_t (parent_, tid_);
         break;
         break;
     case ZMQ_XSUB:
         s = new (std::nothrow) xsub_t (parent_, tid_);
-        break;    
+        break;
     default:
         errno = EINVAL;
         return NULL;
 
 zmq::socket_base_t::socket_base_t (ctx_t *parent_, uint32_t tid_) :
     own_t (parent_, tid_),
+    tag (0xbaddecaf),
     ctx_terminated (false),
     destroyed (false),
     last_tsc (0),
     sessions_sync.lock ();
     zmq_assert (sessions.empty ());
     sessions_sync.unlock ();
+
+    //  Mark the socket as dead.
+    tag = 0xdeadbeef;
 }
 
 zmq::mailbox_t *zmq::socket_base_t::get_mailbox ()
 
         //  For convenience's sake, bind can be used interchageable with
         //  connect for PGM and EPGM transports.
-        return connect (addr_); 
+        return connect (addr_);
     }
 
     zmq_assert (false);
 
 int zmq::socket_base_t::send (::zmq_msg_t *msg_, int flags_)
 {
+    //  Check whether the library haven't been shut down yet.
     if (unlikely (ctx_terminated)) {
         errno = ETERM;
         return -1;
     }
 
+    //  Check whether message passed to the function is valid.
+    if (unlikely ((msg_->flags | ZMQ_MSG_MASK) != 0xff)) {
+        errno = EFAULT;
+        return -1;
+    }
+
     //  Process pending commands, if any.
     int rc = process_commands (false, true);
     if (unlikely (rc != 0))
 
 int zmq::socket_base_t::recv (::zmq_msg_t *msg_, int flags_)
 {
+    //  Check whether the library haven't been shut down yet.
     if (unlikely (ctx_terminated)) {
         errno = ETERM;
         return -1;
     }
 
+    //  Check whether message passed to the function is valid.
+    if (unlikely ((msg_->flags | ZMQ_MSG_MASK) != 0xff)) {
+        errno = EFAULT;
+        return -1;
+    }
+
     //  Get the message.
     int rc = xrecv (msg_, flags_);
     int err = errno;
     session->inc_seqnum ();
 
     sessions_sync.unlock ();
-    return session;    
+    return session;
 }
 
 void zmq::socket_base_t::start_reaping (poller_t *poller_)

src/tcp_connecter.cpp

 
         //  Assert that the error was caused by the networking problems
         //  rather than 0MQ bug.
-        errno = err;
-        errno_assert (errno == WSAECONNREFUSED || errno == WSAETIMEDOUT ||
-            errno == WSAECONNABORTED || errno == WSAEHOSTUNREACH);
+        if (err == WSAECONNREFUSED || err == WSAETIMEDOUT ||
+              err == WSAECONNABORTED || err == WSAEHOSTUNREACH ||
+              err == WSAENETUNREACH || err == WSAENETDOWN)
+            return retired_fd;
 
-        return retired_fd;
+        wsa_assert_no (err);
     }
 
     //  Return the newly connected socket.

src/tcp_listener.cpp

 
 #if (defined ZMQ_HAVE_LINUX || defined ZMQ_HAVE_FREEBSD || \
      defined ZMQ_HAVE_OPENBSD || defined ZMQ_HAVE_OSX || \
-     defined ZMQ_HAVE_OPENVMS || defined ZMQ_HAVE_NETBSD)
+     defined ZMQ_HAVE_OPENVMS || defined ZMQ_HAVE_NETBSD || \
+     defined ZMQ_HAVE_CYGWIN)
     if (sock == -1 && 
         (errno == EAGAIN || errno == EWOULDBLOCK || 
          errno == EINTR || errno == ECONNABORTED))
 {
     DWORD rc = WaitForSingleObject (descriptor, INFINITE);
     win_assert (rc != WAIT_FAILED);
+    BOOL rc2 = CloseHandle (descriptor);
+    win_assert (rc2 != 0);
 }
 
 #else
 
         if (terminating) {
             register_term_acks (1);
-            outpipe_->terminate ();        
+            outpipe_->terminate ();
         }
     }
 
     for (inpipes_t::iterator it = inpipes.begin (); it != inpipes.end ();
           ++it) {
         if (it->reader == pipe_) {
+            if ((inpipes_t::size_type) (it - inpipes.begin ()) < current_in)
+                current_in--;
             inpipes.erase (it);
+            if (current_in >= inpipes.size ())
+                current_in = 0;
             if (terminating)
                 unregister_term_ack ();
-            if (current_in >= inpipes.size ())
-                current_in = 0;
             return;
         }
     }
             zmq_assert (rc == 0);
             memcpy (zmq_msg_data (msg_), inpipes [current_in].identity.data (),
                 zmq_msg_size (msg_));
-            msg_->flags = ZMQ_MSG_MORE;
+            msg_->flags |= ZMQ_MSG_MORE;
             return 0;
         }
 
     return -1;
 }
 
+int zmq::xrep_t::rollback (void)
+{
+    if (current_out) {
+        current_out->rollback ();
+        current_out = NULL;
+        more_out = false;
+    }
+    return 0;
+}
+
 bool zmq::xrep_t::xhas_in ()
 {
     //  There are subsequent parts of the partly-read message available.
 int zmq_msg_init (zmq_msg_t *msg_)
 {
     msg_->content = (zmq::msg_content_t*) ZMQ_VSM;
-    msg_->flags = 0;
+    msg_->flags = (unsigned char) ~ZMQ_MSG_MASK;
     msg_->vsm_size = 0;
     return 0;
 }
 {
     if (size_ <= ZMQ_MAX_VSM_SIZE) {
         msg_->content = (zmq::msg_content_t*) ZMQ_VSM;
-        msg_->flags = 0;
+        msg_->flags = (unsigned char) ~ZMQ_MSG_MASK;
         msg_->vsm_size = (uint8_t) size_;
     }
     else {
             errno = ENOMEM;
             return -1;
         }
-        msg_->flags = 0;
-        
+        msg_->flags = (unsigned char) ~ZMQ_MSG_MASK;
+
         zmq::msg_content_t *content = (zmq::msg_content_t*) msg_->content;
         content->data = (void*) (content + 1);
         content->size = size_;
 {
     msg_->content = (zmq::msg_content_t*) malloc (sizeof (zmq::msg_content_t));
     alloc_assert (msg_->content);
-    msg_->flags = 0;
+    msg_->flags = (unsigned char) ~ZMQ_MSG_MASK;
     zmq::msg_content_t *content = (zmq::msg_content_t*) msg_->content;
     content->data = data_;
     content->size = size_;
 
 int zmq_msg_close (zmq_msg_t *msg_)
 {
+    //  Check the validity tag.
+    if (unlikely (msg_->flags | ZMQ_MSG_MASK) != 0xff) {
+        errno = EFAULT;
+        return -1;
+    }
+
     //  For VSMs and delimiters there are no resources to free.
     if (msg_->content != (zmq::msg_content_t*) ZMQ_DELIMITER &&
           msg_->content != (zmq::msg_content_t*) ZMQ_VSM) {
         }
     }
 
-    //  As a safety measure, let's make the deallocated message look like
-    //  an empty message.
-    msg_->content = (zmq::msg_content_t*) ZMQ_VSM;
+    //  Remove the validity tag from the message.
     msg_->flags = 0;
-    msg_->vsm_size = 0;
 
     return 0;
 }
 
 int zmq_msg_move (zmq_msg_t *dest_, zmq_msg_t *src_)
 {
+#if 0
+    //  Check the validity tags.
+    if (unlikely ((dest_->flags | ZMQ_MSG_MASK) != 0xff ||
+          (src_->flags | ZMQ_MSG_MASK) != 0xff)) {
+        errno = EFAULT;
+        return -1;
+    }
+#endif
     zmq_msg_close (dest_);
     *dest_ = *src_;
     zmq_msg_init (src_);
 
 int zmq_msg_copy (zmq_msg_t *dest_, zmq_msg_t *src_)
 {
+    //  Check the validity tags.
+    if (unlikely ((dest_->flags | ZMQ_MSG_MASK) != 0xff ||
+          (src_->flags | ZMQ_MSG_MASK) != 0xff)) {
+        errno = EFAULT;
+        return -1;
+    }
+
     zmq_msg_close (dest_);
 
     //  VSMs and delimiters require no special handling.
 
 void *zmq_msg_data (zmq_msg_t *msg_)
 {
+    zmq_assert ((msg_->flags | ZMQ_MSG_MASK) == 0xff);
+
     if (msg_->content == (zmq::msg_content_t*) ZMQ_VSM)
         return msg_->vsm_data;
     if (msg_->content == (zmq::msg_content_t*) ZMQ_DELIMITER)
 
 size_t zmq_msg_size (zmq_msg_t *msg_)
 {
+    zmq_assert ((msg_->flags | ZMQ_MSG_MASK) == 0xff);
+
     if (msg_->content == (zmq::msg_content_t*) ZMQ_VSM)
         return msg_->vsm_size;
     if (msg_->content == (zmq::msg_content_t*) ZMQ_DELIMITER)
 
 int zmq_term (void *ctx_)
 {
-    if (!ctx_) {
+    if (!ctx_ || !((zmq::ctx_t*) ctx_)->check_tag ()) {
         errno = EFAULT;
         return -1;
     }
 
 void *zmq_socket (void *ctx_, int type_)
 {
-    if (!ctx_) {
+    if (!ctx_ || !((zmq::ctx_t*) ctx_)->check_tag ()) {
         errno = EFAULT;
         return NULL;
     }
 
 int zmq_close (void *s_)
 {
-    if (!s_) {
-        errno = EFAULT;
+    if (!s_ || !((zmq::socket_base_t*) s_)->check_tag ()) {
+        errno = ENOTSOCK;
         return -1;
     }
     ((zmq::socket_base_t*) s_)->close ();
 int zmq_setsockopt (void *s_, int option_, const void *optval_,
     size_t optvallen_)
 {
-    if (!s_) {
-        errno = EFAULT;
+    if (!s_ || !((zmq::socket_base_t*) s_)->check_tag ()) {
+        errno = ENOTSOCK;
         return -1;
     }
     return (((zmq::socket_base_t*) s_)->setsockopt (option_, optval_,
 
 int zmq_getsockopt (void *s_, int option_, void *optval_, size_t *optvallen_)
 {
-    if (!s_) {
-        errno = EFAULT;
+    if (!s_ || !((zmq::socket_base_t*) s_)->check_tag ()) {
+        errno = ENOTSOCK;
         return -1;
     }
     return (((zmq::socket_base_t*) s_)->getsockopt (option_, optval_,
 
 int zmq_bind (void *s_, const char *addr_)
 {
-    if (!s_) {
-        errno = EFAULT;
+    if (!s_ || !((zmq::socket_base_t*) s_)->check_tag ()) {
+        errno = ENOTSOCK;
         return -1;
     }
     return (((zmq::socket_base_t*) s_)->bind (addr_));
 
 int zmq_connect (void *s_, const char *addr_)
 {
-    if (!s_) {
-        errno = EFAULT;
+    if (!s_ || !((zmq::socket_base_t*) s_)->check_tag ()) {
+        errno = ENOTSOCK;
         return -1;
     }
     return (((zmq::socket_base_t*) s_)->connect (addr_));
 
 int zmq_send (void *s_, zmq_msg_t *msg_, int flags_)
 {
-    if (!s_) {
-        errno = EFAULT;
+    if (!s_ || !((zmq::socket_base_t*) s_)->check_tag ()) {
+        errno = ENOTSOCK;
         return -1;
     }
     return (((zmq::socket_base_t*) s_)->send (msg_, flags_));
 
 int zmq_recv (void *s_, zmq_msg_t *msg_, int flags_)
 {
-    if (!s_) {
-        errno = EFAULT;
+    if (!s_ || !((zmq::socket_base_t*) s_)->check_tag ()) {
+        errno = ENOTSOCK;
         return -1;
     }
     return (((zmq::socket_base_t*) s_)->recv (msg_, flags_));
 #-----------------------------------------------------------------------------
 # Imports
 #-----------------------------------------------------------------------------
+import sys
 
-# First, use ctypes to load the shared library.
-
-import ctypes
-import os
-p = os.path.join(os.path.dirname(__file__), "_zeromq.so")
-_zeromq = ctypes.CDLL(p, mode=ctypes.RTLD_GLOBAL)
-del ctypes, os, p
-
-# Now we can safely proceed to load the Python extensions.
+if sys.platform.startswith('win'):
+    import os, ctypes
+    here = os.path.dirname(__file__)
+    libzmq = os.path.join(here, 'libzmq.dll')
+    if os.path.exists(libzmq):
+        ctypes.cdll.LoadLibrary(libzmq)
+    del here, libzmq, ctypes, os
+else:
+    import ctypes
+    import os
+    p = os.path.join(os.path.dirname(__file__), "_zeromq.so")
+    _zeromq = ctypes.CDLL(p, mode=ctypes.RTLD_GLOBAL)
+    del ctypes, os, p
 
 from zmq.utils import initthreads # initialize threads
 initthreads.init_threads()

zmq/core/constants.c

-/* Generated by Cython 0.14 on Thu Mar  3 00:00:16 2011 */
+/* Generated by Cython 0.14.1 on Fri May 13 15:49:44 2011 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
   #define PyBytes_Repr                 PyString_Repr
   #define PyBytes_Concat               PyString_Concat
   #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
+#endif
+
+#if PY_VERSION_HEX < 0x02060000
   #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
   #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
 #endif
+#ifndef PySet_CheckExact
+  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
+#endif
 
-#ifndef PySet_CheckExact
-#  define PySet_CheckExact(obj)          (Py_TYPE(obj) == &PySet_Type)
-#endif
+#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
 
 #if PY_MAJOR_VERSION >= 3
   #define PyIntObject                  PyLongObject
 #endif
 
 #if PY_MAJOR_VERSION >= 3
-  #define PyBoolObject PyLongObject
+  #define PyBoolObject                 PyLongObject
 #endif
 
 
 
 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
 
+static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
+    if (likely(PyList_CheckExact(L))) {
+        if (PyList_Append(L, x) < 0) return NULL;
+        Py_INCREF(Py_None);
+        return Py_None; /* this is just to have an accurate signature */
+    }
+    else {
+        PyObject *r, *m;
+        m = __Pyx_GetAttrString(L, "append");
+        if (!m) return NULL;
+        r = PyObject_CallFunctionObjArgs(m, x, NULL);
+        Py_DECREF(m);
+        return r;
+    }
+}
+
 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
 
 static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
 /* Module declarations from zmq.core.constants */
 
 #define __Pyx_MODULE_NAME "zmq.core.constants"
-int __pyx_module_is_main_zmq__core__constants = 0;
+static int __pyx_module_is_main_zmq__core__constants = 0;
 
 /* Implementation of zmq.core.constants */
 static char __pyx_k_1[] = "0MQ Constants.";
 static char __pyx_k_2[] = "FD EVENTS TYPE LINGER RECONNECT_IVL BACKLOG";
-static char __pyx_k_3[] = "RECOVERY_IVL_MSEC RECONNECT_IVL_MAX";
 static char __pyx_k__FD[] = "FD";
 static char __pyx_k__HWM[] = "HWM";
 static char __pyx_k__PUB[] = "PUB";
 static char __pyx_k__LINGER[] = "LINGER";
 static char __pyx_k__POLLIN[] = "POLLIN";
 static char __pyx_k__RCVBUF[] = "RCVBUF";
+static char __pyx_k__RCVHWM[] = "RCVHWM";
 static char __pyx_k__SNDBUF[] = "SNDBUF";
+static char __pyx_k__SNDHWM[] = "SNDHWM";
 static char __pyx_k__extend[] = "extend";
 static char __pyx_k__BACKLOG[] = "BACKLOG";
 static char __pyx_k__ENOBUFS[] = "ENOBUFS";
 static char __pyx_k__SNDMORE[] = "SNDMORE";
 static char __pyx_k____all__[] = "__all__";
 static char __pyx_k__AFFINITY[] = "AFFINITY";
+static char __pyx_k__DONTWAIT[] = "DONTWAIT";
 static char __pyx_k__EMTHREAD[] = "EMTHREAD";
 static char __pyx_k__ENETDOWN[] = "ENETDOWN";
 static char __pyx_k__IDENTITY[] = "IDENTITY";
 static char __pyx_k__UPSTREAM[] = "UPSTREAM";
 static char __pyx_k____main__[] = "__main__";
 static char __pyx_k____test__[] = "__test__";
+static char __pyx_k__switched[] = "switched";
 static char __pyx_k__FORWARDER[] = "FORWARDER";
 static char __pyx_k__SUBSCRIBE[] = "SUBSCRIBE";
 static char __pyx_k__DOWNSTREAM[] = "DOWNSTREAM";
 static char __pyx_k__EADDRINUSE[] = "EADDRINUSE";
+static char __pyx_k__MAXMSGSIZE[] = "MAXMSGSIZE";
 static char __pyx_k__MCAST_LOOP[] = "MCAST_LOOP";
 static char __pyx_k___optionals[] = "_optionals";
 static char __pyx_k__EINPROGRESS[] = "EINPROGRESS";
 static char __pyx_k__RECONNECT_IVL_MAX[] = "RECONNECT_IVL_MAX";
 static char __pyx_k__RECOVERY_IVL_MSEC[] = "RECOVERY_IVL_MSEC";
 static PyObject *__pyx_kp_s_2;
-static PyObject *__pyx_kp_s_3;
 static PyObject *__pyx_n_s__AFFINITY;
 static PyObject *__pyx_n_s__BACKLOG;
+static PyObject *__pyx_n_s__DONTWAIT;
 static PyObject *__pyx_n_s__DOWNSTREAM;
 static PyObject *__pyx_n_s__EADDRINUSE;
 static PyObject *__pyx_n_s__EADDRNOTAVAIL;
 static PyObject *__pyx_n_s__HWM;
 static PyObject *__pyx_n_s__IDENTITY;
 static PyObject *__pyx_n_s__LINGER;
+static PyObject *__pyx_n_s__MAXMSGSIZE;
 static PyObject *__pyx_n_s__MCAST_LOOP;
 static PyObject *__pyx_n_s__NOBLOCK;
 static PyObject *__pyx_n_s__PAIR;
 static PyObject *__pyx_n_s__QUEUE;
 static PyObject *__pyx_n_s__RATE;
 static PyObject *__pyx_n_s__RCVBUF;
+static PyObject *__pyx_n_s__RCVHWM;
 static PyObject *__pyx_n_s__RCVMORE;
 static PyObject *__pyx_n_s__RECONNECT_IVL;
 static PyObject *__pyx_n_s__RECONNECT_IVL_MAX;
 static PyObject *__pyx_n_s__REP;
 static PyObject *__pyx_n_s__REQ;
 static PyObject *__pyx_n_s__SNDBUF;
+static PyObject *__pyx_n_s__SNDHWM;
 static PyObject *__pyx_n_s__SNDMORE;
 static PyObject *__pyx_n_s__STREAMER;
 static PyObject *__pyx_n_s__SUB;
 static PyObject *__pyx_n_s__int64_sockopts;
 static PyObject *__pyx_n_s__int_sockopts;
 static PyObject *__pyx_n_s__split;
+static PyObject *__pyx_n_s__switched;
 
 static PyMethodDef __pyx_methods[] = {
   {0, 0, 0, 0}
 
 static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
-  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
   {&__pyx_n_s__AFFINITY, __pyx_k__AFFINITY, sizeof(__pyx_k__AFFINITY), 0, 0, 1, 1},
   {&__pyx_n_s__BACKLOG, __pyx_k__BACKLOG, sizeof(__pyx_k__BACKLOG), 0, 0, 1, 1},
+  {&__pyx_n_s__DONTWAIT, __pyx_k__DONTWAIT, sizeof(__pyx_k__DONTWAIT), 0, 0, 1, 1},
   {&__pyx_n_s__DOWNSTREAM, __pyx_k__DOWNSTREAM, sizeof(__pyx_k__DOWNSTREAM), 0, 0, 1, 1},
   {&__pyx_n_s__EADDRINUSE, __pyx_k__EADDRINUSE, sizeof(__pyx_k__EADDRINUSE), 0, 0, 1, 1},
   {&__pyx_n_s__EADDRNOTAVAIL, __pyx_k__EADDRNOTAVAIL, sizeof(__pyx_k__EADDRNOTAVAIL), 0, 0, 1, 1},
   {&__pyx_n_s__HWM, __pyx_k__HWM, sizeof(__pyx_k__HWM), 0, 0, 1, 1},
   {&__pyx_n_s__IDENTITY, __pyx_k__IDENTITY, sizeof(__pyx_k__IDENTITY), 0, 0, 1, 1},
   {&__pyx_n_s__LINGER, __pyx_k__LINGER, sizeof(__pyx_k__LINGER), 0, 0, 1, 1},
+  {&__pyx_n_s__MAXMSGSIZE, __pyx_k__MAXMSGSIZE, sizeof(__pyx_k__MAXMSGSIZE), 0, 0, 1, 1},
   {&__pyx_n_s__MCAST_LOOP, __pyx_k__MCAST_LOOP, sizeof(__pyx_k__MCAST_LOOP), 0, 0, 1, 1},
   {&__pyx_n_s__NOBLOCK, __pyx_k__NOBLOCK, sizeof(__pyx_k__NOBLOCK), 0, 0, 1, 1},
   {&__pyx_n_s__PAIR, __pyx_k__PAIR, sizeof(__pyx_k__PAIR), 0, 0, 1, 1},
   {&__pyx_n_s__QUEUE, __pyx_k__QUEUE, sizeof(__pyx_k__QUEUE), 0, 0, 1, 1},
   {&__pyx_n_s__RATE, __pyx_k__RATE, sizeof(__pyx_k__RATE), 0, 0, 1, 1},
   {&__pyx_n_s__RCVBUF, __pyx_k__RCVBUF, sizeof(__pyx_k__RCVBUF), 0, 0, 1, 1},
+  {&__pyx_n_s__RCVHWM, __pyx_k__RCVHWM, sizeof(__pyx_k__RCVHWM), 0, 0, 1, 1},
   {&__pyx_n_s__RCVMORE, __pyx_k__RCVMORE, sizeof(__pyx_k__RCVMORE), 0, 0, 1, 1},
   {&__pyx_n_s__RECONNECT_IVL, __pyx_k__RECONNECT_IVL, sizeof(__pyx_k__RECONNECT_IVL), 0, 0, 1, 1},
   {&__pyx_n_s__RECONNECT_IVL_MAX, __pyx_k__RECONNECT_IVL_MAX, sizeof(__pyx_k__RECONNECT_IVL_MAX), 0, 0, 1, 1},
   {&__pyx_n_s__REP, __pyx_k__REP, sizeof(__pyx_k__REP), 0, 0, 1, 1},
   {&__pyx_n_s__REQ, __pyx_k__REQ, sizeof(__pyx_k__REQ), 0, 0, 1, 1},
   {&__pyx_n_s__SNDBUF, __pyx_k__SNDBUF, sizeof(__pyx_k__SNDBUF), 0, 0, 1, 1},
+  {&__pyx_n_s__SNDHWM, __pyx_k__SNDHWM, sizeof(__pyx_k__SNDHWM), 0, 0, 1, 1},
   {&__pyx_n_s__SNDMORE, __pyx_k__SNDMORE, sizeof(__pyx_k__SNDMORE), 0, 0, 1, 1},
   {&__pyx_n_s__STREAMER, __pyx_k__STREAMER, sizeof(__pyx_k__STREAMER), 0, 0, 1, 1},
   {&__pyx_n_s__SUB, __pyx_k__SUB, sizeof(__pyx_k__SUB), 0, 0, 1, 1},
   {&__pyx_n_s__int64_sockopts, __pyx_k__int64_sockopts, sizeof(__pyx_k__int64_sockopts), 0, 0, 1, 1},
   {&__pyx_n_s__int_sockopts, __pyx_k__int_sockopts, sizeof(__pyx_k__int_sockopts), 0, 0, 1, 1},
   {&__pyx_n_s__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1},
+  {&__pyx_n_s__switched, __pyx_k__switched, sizeof(__pyx_k__switched), 0, 0, 1, 1},
   {0, 0, 0, 0, 0, 0, 0}
 };
 static int __Pyx_InitCachedBuiltins(void) {
   PyObject *__pyx_t_7 = NULL;
   PyObject *__pyx_t_8 = NULL;
   PyObject *__pyx_t_9 = NULL;
-  PyObject *__pyx_t_10 = NULL;
-  PyObject *__pyx_t_11 = NULL;
   #if CYTHON_REFNANNY
   void* __pyx_refnanny = NULL;
   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
   /*--- Function import code ---*/
   /*--- Execution code ---*/
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":32
+  /* "zmq/core/constants.pyx":32
  * #-----------------------------------------------------------------------------
  * 
  * _optionals = []             # <<<<<<<<<<<<<<
  * 
- * NOBLOCK = ZMQ_NOBLOCK
+ * if ZMQ_VERSION < 30000:
  */
   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   if (PyObject_SetAttr(__pyx_m, __pyx_n_s___optionals, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":34
+  /* "zmq/core/constants.pyx":34
  * _optionals = []
  * 
- * NOBLOCK = ZMQ_NOBLOCK             # <<<<<<<<<<<<<<
+ * if ZMQ_VERSION < 30000:             # <<<<<<<<<<<<<<
+ *     NOBLOCK = ZMQ_NOBLOCK
+ * else:
+ */
+  __pyx_t_2 = (ZMQ_VERSION < 30000);
+  if (__pyx_t_2) {
+
+    /* "zmq/core/constants.pyx":35
+ * 
+ * if ZMQ_VERSION < 30000:
+ *     NOBLOCK = ZMQ_NOBLOCK             # <<<<<<<<<<<<<<
+ * else:
+ *     # keep NOBLOCK as alias for new DONTWAIT
+ */
+    __pyx_t_1 = PyInt_FromLong(ZMQ_NOBLOCK); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__NOBLOCK, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    goto __pyx_L2;
+  }
+  /*else*/ {
+
+    /* "zmq/core/constants.pyx":38
+ * else:
+ *     # keep NOBLOCK as alias for new DONTWAIT
+ *     NOBLOCK = ZMQ_DONTWAIT             # <<<<<<<<<<<<<<
+ *     DONTWAIT = ZMQ_DONTWAIT
+ *     _optionals.extend(['DONTWAIT'])
+ */
+    __pyx_t_1 = PyInt_FromLong(ZMQ_DONTWAIT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__NOBLOCK, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "zmq/core/constants.pyx":39
+ *     # keep NOBLOCK as alias for new DONTWAIT
+ *     NOBLOCK = ZMQ_DONTWAIT
+ *     DONTWAIT = ZMQ_DONTWAIT             # <<<<<<<<<<<<<<
+ *     _optionals.extend(['DONTWAIT'])
+ * # socket types
+ */
+    __pyx_t_1 = PyInt_FromLong(ZMQ_DONTWAIT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DONTWAIT, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "zmq/core/constants.pyx":40
+ *     NOBLOCK = ZMQ_DONTWAIT
+ *     DONTWAIT = ZMQ_DONTWAIT
+ *     _optionals.extend(['DONTWAIT'])             # <<<<<<<<<<<<<<
  * # socket types
  * PAIR = ZMQ_PAIR
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_NOBLOCK); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__NOBLOCK, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___optionals); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__extend); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __Pyx_INCREF(((PyObject *)__pyx_n_s__DONTWAIT));
+    PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__DONTWAIT));
+    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__DONTWAIT));
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_1));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+    __pyx_t_1 = 0;
+    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  }
+  __pyx_L2:;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":36
- * NOBLOCK = ZMQ_NOBLOCK
+  /* "zmq/core/constants.pyx":42
+ *     _optionals.extend(['DONTWAIT'])
  * # socket types
  * PAIR = ZMQ_PAIR             # <<<<<<<<<<<<<<
  * PUB = ZMQ_PUB
  * SUB = ZMQ_SUB
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_PAIR); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(ZMQ_PAIR); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PAIR, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PAIR, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":37
+  /* "zmq/core/constants.pyx":43
  * # socket types
  * PAIR = ZMQ_PAIR
  * PUB = ZMQ_PUB             # <<<<<<<<<<<<<<
  * SUB = ZMQ_SUB
  * REQ = ZMQ_REQ
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_PUB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(ZMQ_PUB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PUB, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PUB, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":38
+  /* "zmq/core/constants.pyx":44
  * PAIR = ZMQ_PAIR
  * PUB = ZMQ_PUB
  * SUB = ZMQ_SUB             # <<<<<<<<<<<<<<
  * REQ = ZMQ_REQ
  * REP = ZMQ_REP
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_SUB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(ZMQ_SUB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__SUB, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__SUB, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":39
+  /* "zmq/core/constants.pyx":45
  * PUB = ZMQ_PUB
  * SUB = ZMQ_SUB
  * REQ = ZMQ_REQ             # <<<<<<<<<<<<<<
  * REP = ZMQ_REP
  * XREQ = ZMQ_XREQ
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_REQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(ZMQ_REQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__REQ, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__REQ, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":40
+  /* "zmq/core/constants.pyx":46
  * SUB = ZMQ_SUB
  * REQ = ZMQ_REQ
  * REP = ZMQ_REP             # <<<<<<<<<<<<<<
  * XREQ = ZMQ_XREQ
  * XREP = ZMQ_XREP
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_REP); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(ZMQ_REP); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__REP, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__REP, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":41
+  /* "zmq/core/constants.pyx":47
  * REQ = ZMQ_REQ
  * REP = ZMQ_REP
  * XREQ = ZMQ_XREQ             # <<<<<<<<<<<<<<
  * XREP = ZMQ_XREP
  * PULL = ZMQ_PULL
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_XREQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(ZMQ_XREQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__XREQ, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__XREQ, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":42
+  /* "zmq/core/constants.pyx":48
  * REP = ZMQ_REP
  * XREQ = ZMQ_XREQ
  * XREP = ZMQ_XREP             # <<<<<<<<<<<<<<
  * PULL = ZMQ_PULL
  * PUSH = ZMQ_PUSH
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_XREP); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(ZMQ_XREP); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__XREP, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__XREP, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":43
+  /* "zmq/core/constants.pyx":49
  * XREQ = ZMQ_XREQ
  * XREP = ZMQ_XREP
  * PULL = ZMQ_PULL             # <<<<<<<<<<<<<<
  * PUSH = ZMQ_PUSH
- * UPSTREAM = ZMQ_UPSTREAM
+ * if ZMQ_VERSION < 30000:
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_PULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(ZMQ_PULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PULL, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PULL, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":44
+  /* "zmq/core/constants.pyx":50
  * XREP = ZMQ_XREP
  * PULL = ZMQ_PULL
  * PUSH = ZMQ_PUSH             # <<<<<<<<<<<<<<
- * UPSTREAM = ZMQ_UPSTREAM
- * DOWNSTREAM = ZMQ_DOWNSTREAM
+ * if ZMQ_VERSION < 30000:
+ *     UPSTREAM = ZMQ_UPSTREAM
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_PUSH); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(ZMQ_PUSH); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PUSH, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PUSH, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":45
+  /* "zmq/core/constants.pyx":51
  * PULL = ZMQ_PULL
  * PUSH = ZMQ_PUSH
- * UPSTREAM = ZMQ_UPSTREAM             # <<<<<<<<<<<<<<
- * DOWNSTREAM = ZMQ_DOWNSTREAM
+ * if ZMQ_VERSION < 30000:             # <<<<<<<<<<<<<<
+ *     UPSTREAM = ZMQ_UPSTREAM
+ *     DOWNSTREAM = ZMQ_DOWNSTREAM
+ */
+  __pyx_t_2 = (ZMQ_VERSION < 30000);
+  if (__pyx_t_2) {
+
+    /* "zmq/core/constants.pyx":52
+ * PUSH = ZMQ_PUSH
+ * if ZMQ_VERSION < 30000:
+ *     UPSTREAM = ZMQ_UPSTREAM             # <<<<<<<<<<<<<<
+ *     DOWNSTREAM = ZMQ_DOWNSTREAM
+ *     _optionals.extend(['UPSTREAM','DOWNSTREAM'])
+ */
+    __pyx_t_1 = PyInt_FromLong(ZMQ_UPSTREAM); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__UPSTREAM, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "zmq/core/constants.pyx":53
+ * if ZMQ_VERSION < 30000:
+ *     UPSTREAM = ZMQ_UPSTREAM
+ *     DOWNSTREAM = ZMQ_DOWNSTREAM             # <<<<<<<<<<<<<<
+ *     _optionals.extend(['UPSTREAM','DOWNSTREAM'])
  * # new in 2.1.1
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_UPSTREAM); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__UPSTREAM, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_1 = PyInt_FromLong(ZMQ_DOWNSTREAM); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DOWNSTREAM, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":46
- * PUSH = ZMQ_PUSH
- * UPSTREAM = ZMQ_UPSTREAM
- * DOWNSTREAM = ZMQ_DOWNSTREAM             # <<<<<<<<<<<<<<
+    /* "zmq/core/constants.pyx":54
+ *     UPSTREAM = ZMQ_UPSTREAM
+ *     DOWNSTREAM = ZMQ_DOWNSTREAM
+ *     _optionals.extend(['UPSTREAM','DOWNSTREAM'])             # <<<<<<<<<<<<<<
  * # new in 2.1.1
  * if ZMQ_VERSION >= 20101:
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_DOWNSTREAM); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DOWNSTREAM, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___optionals); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__extend); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __Pyx_INCREF(((PyObject *)__pyx_n_s__UPSTREAM));
+    PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__UPSTREAM));
+    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__UPSTREAM));
+    __Pyx_INCREF(((PyObject *)__pyx_n_s__DOWNSTREAM));
+    PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__DOWNSTREAM));
+    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__DOWNSTREAM));
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+    __pyx_t_1 = 0;
+    __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":48
- * DOWNSTREAM = ZMQ_DOWNSTREAM
+  /* "zmq/core/constants.pyx":56
+ *     _optionals.extend(['UPSTREAM','DOWNSTREAM'])
  * # new in 2.1.1
  * if ZMQ_VERSION >= 20101:             # <<<<<<<<<<<<<<
  *     XPUB = ZMQ_XPUB
   __pyx_t_2 = (ZMQ_VERSION >= 20101);
   if (__pyx_t_2) {
 
-    /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":49
+    /* "zmq/core/constants.pyx":57
  * # new in 2.1.1
  * if ZMQ_VERSION >= 20101:
  *     XPUB = ZMQ_XPUB             # <<<<<<<<<<<<<<
  *     XSUB = ZMQ_XSUB
  *     _optionals.extend(['XPUB','XSUB'])
  */
-    __pyx_t_1 = PyInt_FromLong(ZMQ_XPUB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyInt_FromLong(ZMQ_XPUB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__XPUB, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__XPUB, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-    /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":50
+    /* "zmq/core/constants.pyx":58
  * if ZMQ_VERSION >= 20101:
  *     XPUB = ZMQ_XPUB
  *     XSUB = ZMQ_XSUB             # <<<<<<<<<<<<<<
  *     _optionals.extend(['XPUB','XSUB'])
  * 
  */
-    __pyx_t_1 = PyInt_FromLong(ZMQ_XSUB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyInt_FromLong(ZMQ_XSUB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__XSUB, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__XSUB, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-    /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":51
+    /* "zmq/core/constants.pyx":59
  *     XPUB = ZMQ_XPUB
  *     XSUB = ZMQ_XSUB
  *     _optionals.extend(['XPUB','XSUB'])             # <<<<<<<<<<<<<<
  * 
  * # socket options
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___optionals); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___optionals); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__extend); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__extend); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
     __Pyx_INCREF(((PyObject *)__pyx_n_s__XPUB));
     PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__XPUB));
     __Pyx_INCREF(((PyObject *)__pyx_n_s__XSUB));
     PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__XSUB));
     __Pyx_GIVEREF(((PyObject *)__pyx_n_s__XSUB));
-    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
     PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_1));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
     __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    goto __pyx_L2;
+    goto __pyx_L4;
   }
-  __pyx_L2:;
+  __pyx_L4:;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":54
+  /* "zmq/core/constants.pyx":62
  * 
  * # socket options
- * HWM = ZMQ_HWM             # <<<<<<<<<<<<<<
- * SWAP = ZMQ_SWAP
- * AFFINITY = ZMQ_AFFINITY
- */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_HWM); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__HWM, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":55
- * # socket options
- * HWM = ZMQ_HWM
- * SWAP = ZMQ_SWAP             # <<<<<<<<<<<<<<
- * AFFINITY = ZMQ_AFFINITY
- * IDENTITY = ZMQ_IDENTITY
- */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_SWAP); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__SWAP, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":56
- * HWM = ZMQ_HWM
- * SWAP = ZMQ_SWAP
  * AFFINITY = ZMQ_AFFINITY             # <<<<<<<<<<<<<<
  * IDENTITY = ZMQ_IDENTITY
  * SUBSCRIBE = ZMQ_SUBSCRIBE
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_AFFINITY); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(ZMQ_AFFINITY); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__AFFINITY, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__AFFINITY, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":57
- * SWAP = ZMQ_SWAP
+  /* "zmq/core/constants.pyx":63
+ * # socket options
  * AFFINITY = ZMQ_AFFINITY
  * IDENTITY = ZMQ_IDENTITY             # <<<<<<<<<<<<<<
  * SUBSCRIBE = ZMQ_SUBSCRIBE
  * UNSUBSCRIBE = ZMQ_UNSUBSCRIBE
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_IDENTITY); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(ZMQ_IDENTITY); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__IDENTITY, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__IDENTITY, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":58
+  /* "zmq/core/constants.pyx":64
  * AFFINITY = ZMQ_AFFINITY
  * IDENTITY = ZMQ_IDENTITY
  * SUBSCRIBE = ZMQ_SUBSCRIBE             # <<<<<<<<<<<<<<
  * UNSUBSCRIBE = ZMQ_UNSUBSCRIBE
  * RATE = ZMQ_RATE
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_SUBSCRIBE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(ZMQ_SUBSCRIBE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__SUBSCRIBE, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__SUBSCRIBE, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":59
+  /* "zmq/core/constants.pyx":65
  * IDENTITY = ZMQ_IDENTITY
  * SUBSCRIBE = ZMQ_SUBSCRIBE
  * UNSUBSCRIBE = ZMQ_UNSUBSCRIBE             # <<<<<<<<<<<<<<
  * RATE = ZMQ_RATE
  * RECOVERY_IVL = ZMQ_RECOVERY_IVL
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_UNSUBSCRIBE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(ZMQ_UNSUBSCRIBE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__UNSUBSCRIBE, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__UNSUBSCRIBE, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":60
+  /* "zmq/core/constants.pyx":66
  * SUBSCRIBE = ZMQ_SUBSCRIBE
  * UNSUBSCRIBE = ZMQ_UNSUBSCRIBE
  * RATE = ZMQ_RATE             # <<<<<<<<<<<<<<
  * RECOVERY_IVL = ZMQ_RECOVERY_IVL
- * MCAST_LOOP = ZMQ_MCAST_LOOP
+ * SNDBUF = ZMQ_SNDBUF
  */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_RATE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(ZMQ_RATE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__RATE, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__RATE, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":61
+  /* "zmq/core/constants.pyx":67
  * UNSUBSCRIBE = ZMQ_UNSUBSCRIBE
  * RATE = ZMQ_RATE
  * RECOVERY_IVL = ZMQ_RECOVERY_IVL             # <<<<<<<<<<<<<<
- * MCAST_LOOP = ZMQ_MCAST_LOOP
- * SNDBUF = ZMQ_SNDBUF
- */
-  __pyx_t_1 = PyInt_FromLong(ZMQ_RECOVERY_IVL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__RECOVERY_IVL, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "/Users/minrk/dev/ip/pyzmq/zmq/core/constants.pyx":62
- * RATE = ZMQ_RATE
- * RECOVERY_IVL = ZMQ_RECOVERY_IVL
- * MCAST_LOOP = ZMQ_MCAST_LOOP             # <<<<<<<<<<<<<<