/* Generated by Cython 0.15.1 on Mon Dec 19 01:21:36 2011 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#else

#include <stddef.h> /* For offsetof */
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif

#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif

#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif

#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif

#if PY_VERSION_HEX < 0x02040000
  #define METH_COEXIST 0
  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
  #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
#endif

#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   __Pyx_PyInt_AsInt(o)
  #define PyNumber_Index(o)    PyNumber_Int(o)
  #define PyIndex_Check(o)     PyNumber_Check(o)
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
#endif

#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)

  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;

  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)

#endif

#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#endif

#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif

#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif

#if PY_VERSION_HEX < 0x02060000
  #define PyBytesObject                PyStringObject
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_Check                PyString_Check
  #define PyBytes_CheckExact           PyString_CheckExact
  #define PyBytes_FromString           PyString_FromString
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
  #define PyBytes_FromFormat           PyString_FromFormat
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
  #define PyBytes_AsString             PyString_AsString
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
  #define PyBytes_Size                 PyString_Size
  #define PyBytes_AS_STRING            PyString_AS_STRING
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
  #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

#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)

#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif

#if PY_VERSION_HEX < 0x03020000
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif


#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif

#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE__zmq__core__socket
#define __PYX_HAVE_API__zmq__core__socket
#include "allocate.h"
#include "errno.h"
#include "string.h"
#include "zmq_compat.h"
#include "zmq.h"
#include "zmq_utils.h"
#include "pyversion_compat.h"
#include "stdio.h"
#include "pythread.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif


/* inline attribute */
#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

/* unused attribute */
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || defined(__INTEL_COMPILER)
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif

typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/


/* Type Conversion Predeclarations */

#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))

#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);

#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))


#ifdef __GNUC__
  /* Test for GCC > 2.95 */
  #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
    #define likely(x)   __builtin_expect(!!(x), 1)
    #define unlikely(x) __builtin_expect(!!(x), 0)
  #else /* __GNUC__ > 2 ... */
    #define likely(x)   (x)
    #define unlikely(x) (x)
  #endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
    
static PyObject *__pyx_m;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "socket.pyx",
  "socket.pxd",
  "buffers.pxd",
  "message.pxd",
  "context.pxd",
  "bool.pxd",
  "complex.pxd",
};

/*--- Type declarations ---*/
struct __pyx_obj_3zmq_4core_6socket_Socket;
struct __pyx_obj_3zmq_4core_7context_Context;
struct __pyx_obj_3zmq_4core_7message_MessageTracker;
struct __pyx_obj_3zmq_4core_7message_Message;
struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send;
struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv;
struct __pyx_opt_args_3zmq_4core_6socket__recv_message;
struct __pyx_opt_args_3zmq_4core_6socket__recv_copy;
struct __pyx_opt_args_3zmq_4core_6socket__send_message;
struct __pyx_opt_args_3zmq_4core_6socket__send_copy;

/* "zmq/core/socket.pxd":47
 * 
 *     # cpdef methods for direct-cython access:
 *     cpdef object send(self, object data, int flags=*, copy=*, track=*)             # <<<<<<<<<<<<<<
 *     cpdef object recv(self, int flags=*, copy=*, track=*)
 * 
 */
struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send {
  int __pyx_n;
  int flags;
  PyObject *copy;
  PyObject *track;
};

/* "zmq/core/socket.pxd":48
 *     # cpdef methods for direct-cython access:
 *     cpdef object send(self, object data, int flags=*, copy=*, track=*)
 *     cpdef object recv(self, int flags=*, copy=*, track=*)             # <<<<<<<<<<<<<<
 * 
 */
struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv {
  int __pyx_n;
  int flags;
  PyObject *copy;
  PyObject *track;
};

/* "zmq/core/socket.pyx":99
 *     return False
 * 
 * cdef inline Message _recv_message(void *handle, int flags=0, track=False):             # <<<<<<<<<<<<<<
 *     """Receive a message in a non-copying manner and return a Message."""
 *     cdef int rc
 */
struct __pyx_opt_args_3zmq_4core_6socket__recv_message {
  int __pyx_n;
  int flags;
  PyObject *track;
};

/* "zmq/core/socket.pyx":112
 *     return msg
 * 
 * cdef inline object _recv_copy(void *handle, int flags=0):             # <<<<<<<<<<<<<<
 *     """Recieve a message and return a copy"""
 *     cdef zmq_msg_t zmq_msg
 */
struct __pyx_opt_args_3zmq_4core_6socket__recv_copy {
  int __pyx_n;
  int flags;
};

/* "zmq/core/socket.pyx":125
 *     return msg_bytes
 * 
 * cdef inline object _send_message(void *handle, Message msg, int flags=0):             # <<<<<<<<<<<<<<
 *     """Send a Message on this socket in a non-copy manner."""
 *     cdef int rc
 */
struct __pyx_opt_args_3zmq_4core_6socket__send_message {
  int __pyx_n;
  int flags;
};

/* "zmq/core/socket.pyx":144
 * 
 * 
 * cdef inline object _send_copy(void *handle, object msg, int flags=0):             # <<<<<<<<<<<<<<
 *     """Send a message on this socket by copying its content."""
 *     cdef int rc, rc2
 */
struct __pyx_opt_args_3zmq_4core_6socket__send_copy {
  int __pyx_n;
  int flags;
};

/* "zmq/core/socket.pxd":35
 * 
 * 
 * cdef class Socket:             # <<<<<<<<<<<<<<
 *     """A 0MQ socket."""
 * 
 */
struct __pyx_obj_3zmq_4core_6socket_Socket {
  PyObject_HEAD
  struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *__pyx_vtab;
  void *handle;
  int socket_type;
  struct __pyx_obj_3zmq_4core_7context_Context *context;
  int _closed;
  PyObject *_attrs;
};


/* "context.pxd":26
 * #-----------------------------------------------------------------------------
 * 
 * cdef class Context:             # <<<<<<<<<<<<<<
 *     """Manage the lifecycle of a 0MQ context."""
 * 
 */
struct __pyx_obj_3zmq_4core_7context_Context {
  PyObject_HEAD
  struct __pyx_vtabstruct_3zmq_4core_7context_Context *__pyx_vtab;
  void *handle;
  void **_sockets;
  size_t n_sockets;
  size_t max_sockets;
  PyObject *closed;
};


/* "message.pxd":32
 * #-----------------------------------------------------------------------------
 * 
 * cdef class MessageTracker(object):             # <<<<<<<<<<<<<<
 *     """A class for tracking if 0MQ is done using one or more messages."""
 * 
 */
struct __pyx_obj_3zmq_4core_7message_MessageTracker {
  PyObject_HEAD
  PyObject *events;
  PyObject *peers;
};


/* "message.pxd":39
 * 
 * 
 * cdef class Message:             # <<<<<<<<<<<<<<
 *     """A Message class for non-copy send/recvs."""
 * 
 */
struct __pyx_obj_3zmq_4core_7message_Message {
  PyObject_HEAD
  struct __pyx_vtabstruct_3zmq_4core_7message_Message *__pyx_vtab;
  zmq_msg_t zmq_msg;
  PyObject *_data;
  PyObject *_buffer;
  PyObject *_bytes;
  int _failed_init;
  PyObject *tracker_event;
  PyObject *tracker;
};



/* "zmq/core/socket.pyx":171
 * 
 * 
 * cdef class Socket:             # <<<<<<<<<<<<<<
 *     """Socket(context, socket_type)
 * 
 */

struct __pyx_vtabstruct_3zmq_4core_6socket_Socket {
  PyObject *(*send)(struct __pyx_obj_3zmq_4core_6socket_Socket *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send *__pyx_optional_args);
  PyObject *(*recv)(struct __pyx_obj_3zmq_4core_6socket_Socket *, int __pyx_skip_dispatch, struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv *__pyx_optional_args);
};
static struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *__pyx_vtabptr_3zmq_4core_6socket_Socket;


/* "message.pxd":39
 * 
 * 
 * cdef class Message:             # <<<<<<<<<<<<<<
 *     """A Message class for non-copy send/recvs."""
 * 
 */

struct __pyx_vtabstruct_3zmq_4core_7message_Message {
  struct __pyx_obj_3zmq_4core_7message_Message *(*fast_copy)(struct __pyx_obj_3zmq_4core_7message_Message *);
  PyObject *(*_getbuffer)(struct __pyx_obj_3zmq_4core_7message_Message *);
};
static struct __pyx_vtabstruct_3zmq_4core_7message_Message *__pyx_vtabptr_3zmq_4core_7message_Message;


/* "context.pxd":26
 * #-----------------------------------------------------------------------------
 * 
 * cdef class Context:             # <<<<<<<<<<<<<<
 *     """Manage the lifecycle of a 0MQ context."""
 * 
 */

struct __pyx_vtabstruct_3zmq_4core_7context_Context {
  void (*_add_socket)(struct __pyx_obj_3zmq_4core_7context_Context *, void *);
  void (*_remove_socket)(struct __pyx_obj_3zmq_4core_7context_Context *, void *);
};
static struct __pyx_vtabstruct_3zmq_4core_7context_Context *__pyx_vtabptr_3zmq_4core_7context_Context;

#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif

#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  #define __Pyx_RefNannySetupContext(name)           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif /* CYTHON_REFNANNY */

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name, PyObject* kw_name); /*proto*/

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact); /*proto*/

static CYTHON_INLINE int __Pyx_NegateNonNeg(int b) { 
    return unlikely(b < 0) ? b : !b; 
}
static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
    return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void);

#if PY_MAJOR_VERSION >= 3
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    if (unlikely(d == Py_None)) {
        __Pyx_RaiseNoneIndexingError();
        return NULL;
    }
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred())
            PyErr_SetObject(PyExc_KeyError, key);
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#else
    #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#endif

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/


static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}


#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_List_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
            PyObject *r = PyList_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Tuple_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}


#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
    PyObject *r;
    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
        r = PySequence_GetItem(o, i);
    }
    else {
        r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
    }
    return r;
}

static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
    PyObject* value;
#if PY_MAJOR_VERSION >= 3
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (unlikely(PyErr_Occurred()))
            return NULL;
        value = default_value;
    }
    Py_INCREF(value);
#else
    if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
        /* these presumably have safe hash functions */
        value = PyDict_GetItem(d, key);
        if (unlikely(!value)) {
            value = default_value;
        }
        Py_INCREF(value);
    } else {
        PyObject *m;
        m = __Pyx_GetAttrString(d, "get");
        if (!m) return NULL;
        value = PyObject_CallFunctionObjArgs(m, key,
            (default_value == Py_None) ? NULL : default_value, NULL);
        Py_DECREF(m);
    }
#endif
    return value;
}

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/

#ifndef __PYX_FORCE_INIT_THREADS
  #if PY_VERSION_HEX < 0x02040200
    #define __PYX_FORCE_INIT_THREADS 1
  #else
    #define __PYX_FORCE_INIT_THREADS 0
  #endif
#endif

static CYTHON_INLINE pyzmq_int64_t __Pyx_PyInt_from_py_pyzmq_int64_t(PyObject *);

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_pyzmq_int64_t(pyzmq_int64_t);

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_ZMQ_FD_T(ZMQ_FD_T);

static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); /*proto*/

#include <string.h>

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/

#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

static CYTHON_INLINE int __Pyx_StrEq(const char *, const char *); /*proto*/

static int __Pyx_check_binary_version(void);

static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/

static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);  /*proto*/

static PyObject *__Pyx_ImportModule(const char *name); /*proto*/

static void* __Pyx_GetVtable(PyObject *dict); /*proto*/

static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/

static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno,
                               int __pyx_lineno, const char *__pyx_filename); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/

/* Module declarations from 'zmq.core.libzmq' */

/* Module declarations from 'zmq.core.message' */
static PyTypeObject *__pyx_ptype_3zmq_4core_7message_MessageTracker = 0;
static PyTypeObject *__pyx_ptype_3zmq_4core_7message_Message = 0;
static PyObject *(*__pyx_f_3zmq_4core_7message_copy_zmq_msg_bytes)(zmq_msg_t *); /*proto*/

/* Module declarations from 'zmq.core.context' */
static PyTypeObject *__pyx_ptype_3zmq_4core_7context_Context = 0;

/* Module declarations from 'cpython.version' */

/* Module declarations from 'cpython.ref' */

/* Module declarations from 'cpython.exc' */

/* Module declarations from 'cpython.module' */

/* Module declarations from 'cpython.mem' */

/* Module declarations from 'cpython.tuple' */

/* Module declarations from 'cpython.list' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from 'cpython.object' */

/* Module declarations from 'cpython.sequence' */

/* Module declarations from 'cpython.mapping' */

/* Module declarations from 'cpython.iterator' */

/* Module declarations from 'cpython.type' */

/* Module declarations from 'cpython.number' */

/* Module declarations from 'cpython.int' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.bool' */
static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;

/* Module declarations from 'cpython.long' */

/* Module declarations from 'cpython.float' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.complex' */
static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;

/* Module declarations from 'cpython.string' */

/* Module declarations from 'cpython.unicode' */

/* Module declarations from 'cpython.dict' */

/* Module declarations from 'cpython.instance' */

/* Module declarations from 'cpython.function' */

/* Module declarations from 'cpython.method' */

/* Module declarations from 'cpython.weakref' */

/* Module declarations from 'cpython.getargs' */

/* Module declarations from 'cpython.pythread' */

/* Module declarations from 'cpython.pystate' */

/* Module declarations from 'cpython.cobject' */

/* Module declarations from 'cpython.oldbuffer' */

/* Module declarations from 'cpython.set' */

/* Module declarations from 'cpython.buffer' */

/* Module declarations from 'cpython.bytes' */

/* Module declarations from 'cpython.pycapsule' */

/* Module declarations from 'cpython' */

/* Module declarations from 'buffers' */
static CYTHON_INLINE int __pyx_f_7buffers_newstyle_available(void); /*proto*/
static CYTHON_INLINE int __pyx_f_7buffers_memoryview_available(void); /*proto*/
static CYTHON_INLINE int __pyx_f_7buffers_oldstyle_available(void); /*proto*/
static CYTHON_INLINE int __pyx_f_7buffers_check_buffer(PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7buffers_asbuffer(PyObject *, int, int, void **, Py_ssize_t *, Py_ssize_t *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7buffers_asbuffer_r(PyObject *, void **, Py_ssize_t *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7buffers_asbuffer_w(PyObject *, void **, Py_ssize_t *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_3(void *, Py_ssize_t, int); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_2(void *, Py_ssize_t, int); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer(void *, Py_ssize_t, int); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_r(void *, Py_ssize_t); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_w(void *, Py_ssize_t); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7buffers_viewfromobject(PyObject *, int); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7buffers_viewfromobject_r(PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_7buffers_viewfromobject_w(PyObject *); /*proto*/

/* Module declarations from 'zmq.core.socket' */
static PyTypeObject *__pyx_ptype_3zmq_4core_6socket_Socket = 0;
static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__check_closed(struct __pyx_obj_3zmq_4core_6socket_Socket *, int); /*proto*/
static CYTHON_INLINE struct __pyx_obj_3zmq_4core_7message_Message *__pyx_f_3zmq_4core_6socket__recv_message(void *, struct __pyx_opt_args_3zmq_4core_6socket__recv_message *__pyx_optional_args); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__recv_copy(void *, struct __pyx_opt_args_3zmq_4core_6socket__recv_copy *__pyx_optional_args); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__send_message(void *, struct __pyx_obj_3zmq_4core_7message_Message *, struct __pyx_opt_args_3zmq_4core_6socket__send_message *__pyx_optional_args); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__send_copy(void *, PyObject *, struct __pyx_opt_args_3zmq_4core_6socket__send_copy *__pyx_optional_args); /*proto*/
#define __Pyx_MODULE_NAME "zmq.core.socket"
int __pyx_module_is_main_zmq__core__socket = 0;

/* Implementation of 'zmq.core.socket' */
static PyObject *__pyx_builtin_property;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_AttributeError;
static PyObject *__pyx_builtin_xrange;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_ImportError;
static PyObject *__pyx_builtin_NotImplementedError;
static char __pyx_k_2[] = "unicode not allowed, use setsockopt_unicode";
static char __pyx_k_4[] = "expected bytes, got: %r";
static char __pyx_k_5[] = "expected int, got: %r";
static char __pyx_k_6[] = "utf-8";
static char __pyx_k_7[] = "unicode strings only";
static char __pyx_k_9[] = "option %i will not return a string to be decoded";
static char __pyx_k_10[] = "zmq.core.socket";
static char __pyx_k_11[] = "Socket has no such option: %s";
static char __pyx_k_13[] = "expected str, got: %r";
static char __pyx_k_14[] = "%s:%s";
static char __pyx_k_15[] = "Could not bind socket to random port.";
static char __pyx_k_20[] = "unicode not allowed, use send_unicode";
static char __pyx_k_22[] = "Not a tracked message";
static char __pyx_k_31[] = "unicode/str objects only";
static char __pyx_k_33[] = "jsonlib{1,2}, json or simplejson library is required.";
static char __pyx_k_36[] = "%r does not provide a buffer interface.";
static char __pyx_k_37[] = "";
static char __pyx_k_38[] = "New style buffers not available.";
static char __pyx_k_40[] = "Old style buffers not available.";
static char __pyx_k_42[] = "0MQ Socket class.";
static char __pyx_k_43[] = "zmq.utils";
static char __pyx_k_44[] = "zmq.core";
static char __pyx_k_45[] = "zmq.core.constants";
static char __pyx_k_46[] = "*";
static char __pyx_k_47[] = "zmq.core.error";
static char __pyx_k_48[] = "zmq.utils.strtypes";
static char __pyx_k__B[] = "B";
static char __pyx_k__u[] = "u";
static char __pyx_k__obj[] = "obj";
static char __pyx_k__sys[] = "sys";
static char __pyx_k__zmq[] = "zmq";
static char __pyx_k__addr[] = "addr";
static char __pyx_k__bind[] = "bind";
static char __pyx_k__char[] = "char";
static char __pyx_k__copy[] = "copy";
static char __pyx_k__data[] = "data";
static char __pyx_k__poll[] = "poll";
static char __pyx_k__recv[] = "recv";
static char __pyx_k__send[] = "send";
static char __pyx_k__time[] = "time";
static char __pyx_k__bytes[] = "bytes";
static char __pyx_k__close[] = "close";
static char __pyx_k__dtype[] = "dtype";
static char __pyx_k__dumps[] = "dumps";
static char __pyx_k__flags[] = "flags";
static char __pyx_k__loads[] = "loads";
static char __pyx_k__range[] = "range";
static char __pyx_k__track[] = "track";
static char __pyx_k__upper[] = "upper";
static char __pyx_k__POLLIN[] = "POLLIN";
static char __pyx_k__Poller[] = "Poller";
static char __pyx_k__Socket[] = "Socket";
static char __pyx_k__buffer[] = "buffer";
static char __pyx_k__closed[] = "closed";
static char __pyx_k__codecs[] = "codecs";
static char __pyx_k__decode[] = "decode";
static char __pyx_k__encode[] = "encode";
static char __pyx_k__linger[] = "linger";
static char __pyx_k__option[] = "option";
static char __pyx_k__optval[] = "optval";
static char __pyx_k__pickle[] = "pickle";
static char __pyx_k__prefix[] = "prefix";
static char __pyx_k__random[] = "random";
static char __pyx_k__struct[] = "struct";
static char __pyx_k__xrange[] = "xrange";
static char __pyx_k__ENOTSUP[] = "ENOTSUP";
static char __pyx_k__POLLERR[] = "POLLERR";
static char __pyx_k__SNDMORE[] = "SNDMORE";
static char __pyx_k____all__[] = "__all__";
static char __pyx_k___handle[] = "_handle";
static char __pyx_k__cPickle[] = "cPickle";
static char __pyx_k__context[] = "context";
static char __pyx_k__jsonapi[] = "jsonapi";
static char __pyx_k__jsonmod[] = "jsonmod";
static char __pyx_k__timeout[] = "timeout";
static char __pyx_k__tracker[] = "tracker";
static char __pyx_k__unicode[] = "unicode";
static char __pyx_k__ENOTSOCK[] = "ENOTSOCK";
static char __pyx_k__ZMQError[] = "ZMQError";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__copy_mod[] = "copy_mod";
static char __pyx_k__encoding[] = "encoding";
static char __pyx_k__itemsize[] = "itemsize";
static char __pyx_k__max_port[] = "max_port";
static char __pyx_k__min_port[] = "min_port";
static char __pyx_k__property[] = "property";
static char __pyx_k__protocol[] = "protocol";
static char __pyx_k__register[] = "register";
static char __pyx_k__typecode[] = "typecode";
static char __pyx_k__TypeError[] = "TypeError";
static char __pyx_k____class__[] = "__class__";
static char __pyx_k__constants[] = "constants";
static char __pyx_k__max_tries[] = "max_tries";
static char __pyx_k__msg_parts[] = "msg_parts";
static char __pyx_k__randrange[] = "randrange";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k____module__[] = "__module__";
static char __pyx_k__basestring[] = "basestring";
static char __pyx_k__getsockopt[] = "getsockopt";
static char __pyx_k__setsockopt[] = "setsockopt";
static char __pyx_k__ImportError[] = "ImportError";
static char __pyx_k__socket_type[] = "socket_type";
static char __pyx_k__ZMQBindError[] = "ZMQBindError";
static char __pyx_k__AttributeError[] = "AttributeError";
static char __pyx_k__bytes_sockopts[] = "bytes_sockopts";
static char __pyx_k__int64_sockopts[] = "int64_sockopts";
static char __pyx_k__NotImplementedError[] = "NotImplementedError";
static PyObject *__pyx_kp_s_10;
static PyObject *__pyx_kp_s_11;
static PyObject *__pyx_kp_s_13;
static PyObject *__pyx_kp_s_14;
static PyObject *__pyx_kp_s_15;
static PyObject *__pyx_kp_s_2;
static PyObject *__pyx_kp_s_20;
static PyObject *__pyx_kp_s_22;
static PyObject *__pyx_kp_s_31;
static PyObject *__pyx_kp_s_33;
static PyObject *__pyx_kp_s_36;
static PyObject *__pyx_kp_s_37;
static PyObject *__pyx_kp_s_38;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_kp_s_40;
static PyObject *__pyx_n_s_43;
static PyObject *__pyx_n_s_44;
static PyObject *__pyx_n_s_45;
static PyObject *__pyx_n_s_46;
static PyObject *__pyx_n_s_47;
static PyObject *__pyx_n_s_48;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_kp_s_6;
static PyObject *__pyx_kp_s_7;
static PyObject *__pyx_kp_s_9;
static PyObject *__pyx_n_s__AttributeError;
static PyObject *__pyx_n_s__B;
static PyObject *__pyx_n_s__ENOTSOCK;
static PyObject *__pyx_n_s__ENOTSUP;
static PyObject *__pyx_n_s__ImportError;
static PyObject *__pyx_n_s__NotImplementedError;
static PyObject *__pyx_n_s__POLLERR;
static PyObject *__pyx_n_s__POLLIN;
static PyObject *__pyx_n_s__Poller;
static PyObject *__pyx_n_s__SNDMORE;
static PyObject *__pyx_n_s__Socket;
static PyObject *__pyx_n_s__TypeError;
static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s__ZMQBindError;
static PyObject *__pyx_n_s__ZMQError;
static PyObject *__pyx_n_s____all__;
static PyObject *__pyx_n_s____class__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____module__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___handle;
static PyObject *__pyx_n_s__addr;
static PyObject *__pyx_n_s__basestring;
static PyObject *__pyx_n_s__bind;
static PyObject *__pyx_n_s__buffer;
static PyObject *__pyx_n_s__bytes;
static PyObject *__pyx_n_s__bytes_sockopts;
static PyObject *__pyx_n_s__cPickle;
static PyObject *__pyx_n_s__char;
static PyObject *__pyx_n_s__close;
static PyObject *__pyx_n_s__closed;
static PyObject *__pyx_n_s__codecs;
static PyObject *__pyx_n_s__constants;
static PyObject *__pyx_n_s__context;
static PyObject *__pyx_n_s__copy;
static PyObject *__pyx_n_s__copy_mod;
static PyObject *__pyx_n_s__data;
static PyObject *__pyx_n_s__decode;
static PyObject *__pyx_n_s__dtype;
static PyObject *__pyx_n_s__dumps;
static PyObject *__pyx_n_s__encode;
static PyObject *__pyx_n_s__encoding;
static PyObject *__pyx_n_s__flags;
static PyObject *__pyx_n_s__getsockopt;
static PyObject *__pyx_n_s__int64_sockopts;
static PyObject *__pyx_n_s__itemsize;
static PyObject *__pyx_n_s__jsonapi;
static PyObject *__pyx_n_s__jsonmod;
static PyObject *__pyx_n_s__linger;
static PyObject *__pyx_n_s__loads;
static PyObject *__pyx_n_s__max_port;
static PyObject *__pyx_n_s__max_tries;
static PyObject *__pyx_n_s__min_port;
static PyObject *__pyx_n_s__msg_parts;
static PyObject *__pyx_n_s__obj;
static PyObject *__pyx_n_s__option;
static PyObject *__pyx_n_s__optval;
static PyObject *__pyx_n_s__pickle;
static PyObject *__pyx_n_s__poll;
static PyObject *__pyx_n_s__prefix;
static PyObject *__pyx_n_s__property;
static PyObject *__pyx_n_s__protocol;
static PyObject *__pyx_n_s__random;
static PyObject *__pyx_n_s__randrange;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__recv;
static PyObject *__pyx_n_s__register;
static PyObject *__pyx_n_s__send;
static PyObject *__pyx_n_s__setsockopt;
static PyObject *__pyx_n_s__socket_type;
static PyObject *__pyx_n_s__struct;
static PyObject *__pyx_n_s__sys;
static PyObject *__pyx_n_s__time;
static PyObject *__pyx_n_s__timeout;
static PyObject *__pyx_n_s__track;
static PyObject *__pyx_n_s__tracker;
static PyObject *__pyx_n_s__typecode;
static PyObject *__pyx_n_s__u;
static PyObject *__pyx_n_s__unicode;
static PyObject *__pyx_n_s__upper;
static PyObject *__pyx_n_s__xrange;
static PyObject *__pyx_n_s__zmq;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_int_100;
static PyObject *__pyx_int_49152;
static PyObject *__pyx_int_65536;
static PyObject *__pyx_k_1;
static PyObject *__pyx_k_18;
static PyObject *__pyx_k_19;
static PyObject *__pyx_k_24;
static PyObject *__pyx_k_25;
static PyObject *__pyx_k_26;
static PyObject *__pyx_k_27;
static PyObject *__pyx_k_28;
static PyObject *__pyx_k_29;
static PyObject *__pyx_k_30;
static PyObject *__pyx_k_tuple_3;
static PyObject *__pyx_k_tuple_8;
static PyObject *__pyx_k_tuple_12;
static PyObject *__pyx_k_tuple_16;
static PyObject *__pyx_k_tuple_17;
static PyObject *__pyx_k_tuple_21;
static PyObject *__pyx_k_tuple_23;
static PyObject *__pyx_k_tuple_32;
static PyObject *__pyx_k_tuple_34;
static PyObject *__pyx_k_tuple_35;
static PyObject *__pyx_k_tuple_39;
static PyObject *__pyx_k_tuple_41;

/* "zmq/core/socket.pyx":77
 * # true methods frequently cannot be inlined, acc. Cython docs
 * 
 * cdef inline _check_closed(Socket s, bint raise_notsup):             # <<<<<<<<<<<<<<
 *     cdef int rc
 *     cdef int errno
 */

static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__check_closed(struct __pyx_obj_3zmq_4core_6socket_Socket *__pyx_v_s, int __pyx_v_raise_notsup) {
  int __pyx_v_rc;
  int __pyx_v_stype;
  size_t __pyx_v_sz;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_check_closed");

  /* "zmq/core/socket.pyx":81
 *     cdef int errno
 *     cdef int stype
 *     cdef size_t sz=sizeof(int)             # <<<<<<<<<<<<<<
 *     if s._closed:
 *         if raise_notsup:
 */
  __pyx_v_sz = (sizeof(int));

  /* "zmq/core/socket.pyx":82
 *     cdef int stype
 *     cdef size_t sz=sizeof(int)
 *     if s._closed:             # <<<<<<<<<<<<<<
 *         if raise_notsup:
 *             raise ZMQError(ENOTSUP)
 */
  if (__pyx_v_s->_closed) {

    /* "zmq/core/socket.pyx":83
 *     cdef size_t sz=sizeof(int)
 *     if s._closed:
 *         if raise_notsup:             # <<<<<<<<<<<<<<
 *             raise ZMQError(ENOTSUP)
 *         else:
 */
    if (__pyx_v_raise_notsup) {

      /* "zmq/core/socket.pyx":84
 *     if s._closed:
 *         if raise_notsup:
 *             raise ZMQError(ENOTSUP)             # <<<<<<<<<<<<<<
 *         else:
 *             return True
 */
      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__ENOTSUP); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L4;
    }
    /*else*/ {

      /* "zmq/core/socket.pyx":86
 *             raise ZMQError(ENOTSUP)
 *         else:
 *             return True             # <<<<<<<<<<<<<<
 *     else:
 *         rc = zmq_getsockopt(s.handle, ZMQ_TYPE, <void *>&stype, &sz)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "zmq/core/socket.pyx":88
 *             return True
 *     else:
 *         rc = zmq_getsockopt(s.handle, ZMQ_TYPE, <void *>&stype, &sz)             # <<<<<<<<<<<<<<
 *         if rc and zmq_errno() == ENOTSOCK:
 *             s._closed = True
 */
    __pyx_v_rc = zmq_getsockopt(__pyx_v_s->handle, ZMQ_TYPE, ((void *)(&__pyx_v_stype)), (&__pyx_v_sz));

    /* "zmq/core/socket.pyx":89
 *     else:
 *         rc = zmq_getsockopt(s.handle, ZMQ_TYPE, <void *>&stype, &sz)
 *         if rc and zmq_errno() == ENOTSOCK:             # <<<<<<<<<<<<<<
 *             s._closed = True
 *             if raise_notsup:
 */
    if (__pyx_v_rc) {
      __pyx_t_2 = PyInt_FromLong(zmq_errno()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ENOTSOCK); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = __pyx_t_4;
    } else {
      __pyx_t_5 = __pyx_v_rc;
    }
    if (__pyx_t_5) {

      /* "zmq/core/socket.pyx":90
 *         rc = zmq_getsockopt(s.handle, ZMQ_TYPE, <void *>&stype, &sz)
 *         if rc and zmq_errno() == ENOTSOCK:
 *             s._closed = True             # <<<<<<<<<<<<<<
 *             if raise_notsup:
 *                 raise ZMQError(ENOTSUP)
 */
      __pyx_v_s->_closed = 1;

      /* "zmq/core/socket.pyx":91
 *         if rc and zmq_errno() == ENOTSOCK:
 *             s._closed = True
 *             if raise_notsup:             # <<<<<<<<<<<<<<
 *                 raise ZMQError(ENOTSUP)
 *             else:
 */
      if (__pyx_v_raise_notsup) {

        /* "zmq/core/socket.pyx":92
 *             s._closed = True
 *             if raise_notsup:
 *                 raise ZMQError(ENOTSUP)             # <<<<<<<<<<<<<<
 *             else:
 *                 return True
 */
        __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ENOTSUP); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L6;
      }
      /*else*/ {

        /* "zmq/core/socket.pyx":94
 *                 raise ZMQError(ENOTSUP)
 *             else:
 *                 return True             # <<<<<<<<<<<<<<
 *         elif rc:
 *             raise ZMQError()
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_r = __pyx_t_3;
        __pyx_t_3 = 0;
        goto __pyx_L0;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }

    /* "zmq/core/socket.pyx":95
 *             else:
 *                 return True
 *         elif rc:             # <<<<<<<<<<<<<<
 *             raise ZMQError()
 *     return False
 */
    if (__pyx_v_rc) {

      /* "zmq/core/socket.pyx":96
 *                 return True
 *         elif rc:
 *             raise ZMQError()             # <<<<<<<<<<<<<<
 *     return False
 * 
 */
      __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  __pyx_L3:;

  /* "zmq/core/socket.pyx":97
 *         elif rc:
 *             raise ZMQError()
 *     return False             # <<<<<<<<<<<<<<
 * 
 * cdef inline Message _recv_message(void *handle, int flags=0, track=False):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("zmq.core.socket._check_closed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":99
 *     return False
 * 
 * cdef inline Message _recv_message(void *handle, int flags=0, track=False):             # <<<<<<<<<<<<<<
 *     """Receive a message in a non-copying manner and return a Message."""
 *     cdef int rc
 */

static CYTHON_INLINE struct __pyx_obj_3zmq_4core_7message_Message *__pyx_f_3zmq_4core_6socket__recv_message(void *__pyx_v_handle, struct __pyx_opt_args_3zmq_4core_6socket__recv_message *__pyx_optional_args) {
  int __pyx_v_flags = ((int)0);
  PyObject *__pyx_v_track = __pyx_k_1;
  int __pyx_v_rc;
  struct __pyx_obj_3zmq_4core_7message_Message *__pyx_v_msg = 0;
  struct __pyx_obj_3zmq_4core_7message_Message *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_recv_message");
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_flags = __pyx_optional_args->flags;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_track = __pyx_optional_args->track;
      }
    }
  }

  /* "zmq/core/socket.pyx":103
 *     cdef int rc
 *     cdef Message msg
 *     msg = Message(track=track)             # <<<<<<<<<<<<<<
 * 
 *     with nogil:
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__track), __pyx_v_track) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_3zmq_4core_7message_Message)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_msg = ((struct __pyx_obj_3zmq_4core_7message_Message *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "zmq/core/socket.pyx":105
 *     msg = Message(track=track)
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         rc = zmq_recvmsg(handle, &msg.zmq_msg, flags)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "zmq/core/socket.pyx":106
 * 
 *     with nogil:
 *         rc = zmq_recvmsg(handle, &msg.zmq_msg, flags)             # <<<<<<<<<<<<<<
 * 
 *     if rc < 0:
 */
        __pyx_v_rc = zmq_recvmsg(__pyx_v_handle, (&__pyx_v_msg->zmq_msg), __pyx_v_flags);
      }

      /* "zmq/core/socket.pyx":105
 *     msg = Message(track=track)
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         rc = zmq_recvmsg(handle, &msg.zmq_msg, flags)
 * 
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "zmq/core/socket.pyx":108
 *         rc = zmq_recvmsg(handle, &msg.zmq_msg, flags)
 * 
 *     if rc < 0:             # <<<<<<<<<<<<<<
 *         raise ZMQError()
 *     return msg
 */
  __pyx_t_3 = (__pyx_v_rc < 0);
  if (__pyx_t_3) {

    /* "zmq/core/socket.pyx":109
 * 
 *     if rc < 0:
 *         raise ZMQError()             # <<<<<<<<<<<<<<
 *     return msg
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "zmq/core/socket.pyx":110
 *     if rc < 0:
 *         raise ZMQError()
 *     return msg             # <<<<<<<<<<<<<<
 * 
 * cdef inline object _recv_copy(void *handle, int flags=0):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_msg));
  __pyx_r = __pyx_v_msg;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_3zmq_4core_7message_Message *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("zmq.core.socket._recv_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_msg);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":112
 *     return msg
 * 
 * cdef inline object _recv_copy(void *handle, int flags=0):             # <<<<<<<<<<<<<<
 *     """Recieve a message and return a copy"""
 *     cdef zmq_msg_t zmq_msg
 */

static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__recv_copy(void *__pyx_v_handle, struct __pyx_opt_args_3zmq_4core_6socket__recv_copy *__pyx_optional_args) {
  int __pyx_v_flags = ((int)0);
  zmq_msg_t __pyx_v_zmq_msg;
  int __pyx_v_rc;
  PyObject *__pyx_v_msg_bytes = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_recv_copy");
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_flags = __pyx_optional_args->flags;
    }
  }

  /* "zmq/core/socket.pyx":115
 *     """Recieve a message and return a copy"""
 *     cdef zmq_msg_t zmq_msg
 *     with nogil:             # <<<<<<<<<<<<<<
 *         zmq_msg_init (&zmq_msg)
 *         rc = zmq_recvmsg(handle, &zmq_msg, flags)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "zmq/core/socket.pyx":116
 *     cdef zmq_msg_t zmq_msg
 *     with nogil:
 *         zmq_msg_init (&zmq_msg)             # <<<<<<<<<<<<<<
 *         rc = zmq_recvmsg(handle, &zmq_msg, flags)
 *     if rc < 0:
 */
        zmq_msg_init((&__pyx_v_zmq_msg));

        /* "zmq/core/socket.pyx":117
 *     with nogil:
 *         zmq_msg_init (&zmq_msg)
 *         rc = zmq_recvmsg(handle, &zmq_msg, flags)             # <<<<<<<<<<<<<<
 *     if rc < 0:
 *         raise ZMQError()
 */
        __pyx_v_rc = zmq_recvmsg(__pyx_v_handle, (&__pyx_v_zmq_msg), __pyx_v_flags);
      }

      /* "zmq/core/socket.pyx":115
 *     """Recieve a message and return a copy"""
 *     cdef zmq_msg_t zmq_msg
 *     with nogil:             # <<<<<<<<<<<<<<
 *         zmq_msg_init (&zmq_msg)
 *         rc = zmq_recvmsg(handle, &zmq_msg, flags)
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "zmq/core/socket.pyx":118
 *         zmq_msg_init (&zmq_msg)
 *         rc = zmq_recvmsg(handle, &zmq_msg, flags)
 *     if rc < 0:             # <<<<<<<<<<<<<<
 *         raise ZMQError()
 *     msg_bytes = copy_zmq_msg_bytes(&zmq_msg)
 */
  __pyx_t_1 = (__pyx_v_rc < 0);
  if (__pyx_t_1) {

    /* "zmq/core/socket.pyx":119
 *         rc = zmq_recvmsg(handle, &zmq_msg, flags)
 *     if rc < 0:
 *         raise ZMQError()             # <<<<<<<<<<<<<<
 *     msg_bytes = copy_zmq_msg_bytes(&zmq_msg)
 *     with nogil:
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "zmq/core/socket.pyx":120
 *     if rc < 0:
 *         raise ZMQError()
 *     msg_bytes = copy_zmq_msg_bytes(&zmq_msg)             # <<<<<<<<<<<<<<
 *     with nogil:
 *         zmq_msg_close(&zmq_msg)
 */
  __pyx_t_3 = __pyx_f_3zmq_4core_7message_copy_zmq_msg_bytes((&__pyx_v_zmq_msg)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_msg_bytes = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "zmq/core/socket.pyx":121
 *         raise ZMQError()
 *     msg_bytes = copy_zmq_msg_bytes(&zmq_msg)
 *     with nogil:             # <<<<<<<<<<<<<<
 *         zmq_msg_close(&zmq_msg)
 *     return msg_bytes
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "zmq/core/socket.pyx":122
 *     msg_bytes = copy_zmq_msg_bytes(&zmq_msg)
 *     with nogil:
 *         zmq_msg_close(&zmq_msg)             # <<<<<<<<<<<<<<
 *     return msg_bytes
 * 
 */
        zmq_msg_close((&__pyx_v_zmq_msg));
      }

      /* "zmq/core/socket.pyx":121
 *         raise ZMQError()
 *     msg_bytes = copy_zmq_msg_bytes(&zmq_msg)
 *     with nogil:             # <<<<<<<<<<<<<<
 *         zmq_msg_close(&zmq_msg)
 *     return msg_bytes
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "zmq/core/socket.pyx":123
 *     with nogil:
 *         zmq_msg_close(&zmq_msg)
 *     return msg_bytes             # <<<<<<<<<<<<<<
 * 
 * cdef inline object _send_message(void *handle, Message msg, int flags=0):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_msg_bytes);
  __pyx_r = __pyx_v_msg_bytes;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("zmq.core.socket._recv_copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_msg_bytes);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":125
 *     return msg_bytes
 * 
 * cdef inline object _send_message(void *handle, Message msg, int flags=0):             # <<<<<<<<<<<<<<
 *     """Send a Message on this socket in a non-copy manner."""
 *     cdef int rc
 */

static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__send_message(void *__pyx_v_handle, struct __pyx_obj_3zmq_4core_7message_Message *__pyx_v_msg, struct __pyx_opt_args_3zmq_4core_6socket__send_message *__pyx_optional_args) {
  int __pyx_v_flags = ((int)0);
  int __pyx_v_rc;
  struct __pyx_obj_3zmq_4core_7message_Message *__pyx_v_msg_copy = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_send_message");
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_flags = __pyx_optional_args->flags;
    }
  }

  /* "zmq/core/socket.pyx":132
 *     # Always copy so the original message isn't garbage collected.
 *     # This doesn't do a real copy, just a reference.
 *     msg_copy = msg.fast_copy()             # <<<<<<<<<<<<<<
 * 
 *     with nogil:
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_3zmq_4core_7message_Message *)__pyx_v_msg->__pyx_vtab)->fast_copy(__pyx_v_msg)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_msg_copy = ((struct __pyx_obj_3zmq_4core_7message_Message *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "zmq/core/socket.pyx":134
 *     msg_copy = msg.fast_copy()
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         rc = zmq_sendmsg(handle, &msg_copy.zmq_msg, flags)
 * 
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "zmq/core/socket.pyx":135
 * 
 *     with nogil:
 *         rc = zmq_sendmsg(handle, &msg_copy.zmq_msg, flags)             # <<<<<<<<<<<<<<
 * 
 *     if rc < 0:
 */
        __pyx_v_rc = zmq_sendmsg(__pyx_v_handle, (&__pyx_v_msg_copy->zmq_msg), __pyx_v_flags);
      }

      /* "zmq/core/socket.pyx":134
 *     msg_copy = msg.fast_copy()
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         rc = zmq_sendmsg(handle, &msg_copy.zmq_msg, flags)
 * 
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "zmq/core/socket.pyx":137
 *         rc = zmq_sendmsg(handle, &msg_copy.zmq_msg, flags)
 * 
 *     if rc < 0:             # <<<<<<<<<<<<<<
 *         # don't pop from the Queue here, because the free_fn will
 *         #  still call Queue.get() even if the send fails
 */
  __pyx_t_2 = (__pyx_v_rc < 0);
  if (__pyx_t_2) {

    /* "zmq/core/socket.pyx":140
 *         # don't pop from the Queue here, because the free_fn will
 *         #  still call Queue.get() even if the send fails
 *         raise ZMQError()             # <<<<<<<<<<<<<<
 *     return msg.tracker
 * 
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "zmq/core/socket.pyx":141
 *         #  still call Queue.get() even if the send fails
 *         raise ZMQError()
 *     return msg.tracker             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_msg->tracker);
  __pyx_r = __pyx_v_msg->tracker;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("zmq.core.socket._send_message", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_msg_copy);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":144
 * 
 * 
 * cdef inline object _send_copy(void *handle, object msg, int flags=0):             # <<<<<<<<<<<<<<
 *     """Send a message on this socket by copying its content."""
 *     cdef int rc, rc2
 */

static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__send_copy(void *__pyx_v_handle, PyObject *__pyx_v_msg, struct __pyx_opt_args_3zmq_4core_6socket__send_copy *__pyx_optional_args) {
  int __pyx_v_flags = ((int)0);
  int __pyx_v_rc;
  int __pyx_v_rc2;
  zmq_msg_t __pyx_v_data;
  char *__pyx_v_msg_c;
  Py_ssize_t __pyx_v_msg_c_len;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_send_copy");
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_flags = __pyx_optional_args->flags;
    }
  }

  /* "zmq/core/socket.pyx":149
 *     cdef zmq_msg_t data
 *     cdef char *msg_c
 *     cdef Py_ssize_t msg_c_len=0             # <<<<<<<<<<<<<<
 * 
 *     # copy to c array:
 */
  __pyx_v_msg_c_len = 0;

  /* "zmq/core/socket.pyx":152
 * 
 *     # copy to c array:
 *     asbuffer_r(msg, <void **>&msg_c, &msg_c_len)             # <<<<<<<<<<<<<<
 * 
 *     # Copy the msg before sending. This avoids any complications with
 */
  __pyx_t_1 = __pyx_f_7buffers_asbuffer_r(__pyx_v_msg, ((void **)(&__pyx_v_msg_c)), (&__pyx_v_msg_c_len)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "zmq/core/socket.pyx":157
 *     # the GIL, etc.
 *     # If zmq_msg_init_* fails we must not call zmq_msg_close (Bus Error)
 *     with nogil:             # <<<<<<<<<<<<<<
 *         rc = zmq_msg_init_size(&data, msg_c_len)
 *         memcpy(zmq_msg_data(&data), msg_c, zmq_msg_size(&data))
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "zmq/core/socket.pyx":158
 *     # If zmq_msg_init_* fails we must not call zmq_msg_close (Bus Error)
 *     with nogil:
 *         rc = zmq_msg_init_size(&data, msg_c_len)             # <<<<<<<<<<<<<<
 *         memcpy(zmq_msg_data(&data), msg_c, zmq_msg_size(&data))
 * 
 */
        __pyx_v_rc = zmq_msg_init_size((&__pyx_v_data), __pyx_v_msg_c_len);

        /* "zmq/core/socket.pyx":159
 *     with nogil:
 *         rc = zmq_msg_init_size(&data, msg_c_len)
 *         memcpy(zmq_msg_data(&data), msg_c, zmq_msg_size(&data))             # <<<<<<<<<<<<<<
 * 
 *     if rc != 0:
 */
        memcpy(zmq_msg_data((&__pyx_v_data)), __pyx_v_msg_c, zmq_msg_size((&__pyx_v_data)));
      }

      /* "zmq/core/socket.pyx":157
 *     # the GIL, etc.
 *     # If zmq_msg_init_* fails we must not call zmq_msg_close (Bus Error)
 *     with nogil:             # <<<<<<<<<<<<<<
 *         rc = zmq_msg_init_size(&data, msg_c_len)
 *         memcpy(zmq_msg_data(&data), msg_c, zmq_msg_size(&data))
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "zmq/core/socket.pyx":161
 *         memcpy(zmq_msg_data(&data), msg_c, zmq_msg_size(&data))
 * 
 *     if rc != 0:             # <<<<<<<<<<<<<<
 *         raise ZMQError()
 * 
 */
  __pyx_t_2 = (__pyx_v_rc != 0);
  if (__pyx_t_2) {

    /* "zmq/core/socket.pyx":162
 * 
 *     if rc != 0:
 *         raise ZMQError()             # <<<<<<<<<<<<<<
 * 
 *     with nogil:
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "zmq/core/socket.pyx":164
 *         raise ZMQError()
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         rc = zmq_sendmsg(handle, &data, flags)
 *         rc2 = zmq_msg_close(&data)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "zmq/core/socket.pyx":165
 * 
 *     with nogil:
 *         rc = zmq_sendmsg(handle, &data, flags)             # <<<<<<<<<<<<<<
 *         rc2 = zmq_msg_close(&data)
 *     if rc < 0 or rc2 != 0:
 */
        __pyx_v_rc = zmq_sendmsg(__pyx_v_handle, (&__pyx_v_data), __pyx_v_flags);

        /* "zmq/core/socket.pyx":166
 *     with nogil:
 *         rc = zmq_sendmsg(handle, &data, flags)
 *         rc2 = zmq_msg_close(&data)             # <<<<<<<<<<<<<<
 *     if rc < 0 or rc2 != 0:
 *         raise ZMQError()
 */
        __pyx_v_rc2 = zmq_msg_close((&__pyx_v_data));
      }

      /* "zmq/core/socket.pyx":164
 *         raise ZMQError()
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         rc = zmq_sendmsg(handle, &data, flags)
 *         rc2 = zmq_msg_close(&data)
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "zmq/core/socket.pyx":167
 *         rc = zmq_sendmsg(handle, &data, flags)
 *         rc2 = zmq_msg_close(&data)
 *     if rc < 0 or rc2 != 0:             # <<<<<<<<<<<<<<
 *         raise ZMQError()
 * 
 */
  __pyx_t_2 = (__pyx_v_rc < 0);
  if (!__pyx_t_2) {
    __pyx_t_4 = (__pyx_v_rc2 != 0);
    __pyx_t_5 = __pyx_t_4;
  } else {
    __pyx_t_5 = __pyx_t_2;
  }
  if (__pyx_t_5) {

    /* "zmq/core/socket.pyx":168
 *         rc2 = zmq_msg_close(&data)
 *     if rc < 0 or rc2 != 0:
 *         raise ZMQError()             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L10;
  }
  __pyx_L10:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("zmq.core.socket._send_copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":193
 *     """
 * 
 *     def __cinit__(self, Context context, int socket_type, *args, **kwrags):             # <<<<<<<<<<<<<<
 *         cdef Py_ssize_t c_handle
 *         c_handle = context._handle
 */

static int __pyx_pf_3zmq_4core_6socket_6Socket___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_3zmq_4core_6socket_6Socket___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_3zmq_4core_7context_Context *__pyx_v_context = 0;
  int __pyx_v_socket_type;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kwrags = 0;
  Py_ssize_t __pyx_v_c_handle;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__context,&__pyx_n_s__socket_type,0};
  __Pyx_RefNannySetupContext("__cinit__");
  __pyx_v_kwrags = PyDict_New(); if (unlikely(!__pyx_v_kwrags)) return -1;
  __Pyx_GOTREF(__pyx_v_kwrags);
  if (PyTuple_GET_SIZE(__pyx_args) > 2) {
    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 2, PyTuple_GET_SIZE(__pyx_args));
    if (unlikely(!__pyx_v_args)) {
      __Pyx_DECREF(__pyx_v_kwrags); __pyx_v_kwrags = 0;
      __Pyx_RefNannyFinishContext();
      return -1;
    }
    __Pyx_GOTREF(__pyx_v_args);
  } else {
    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
  }
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        default:
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__context);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__socket_type);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(__pyx_args) < 2) ? PyTuple_GET_SIZE(__pyx_args) : 2;
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwrags, values, used_pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) < 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_context = ((struct __pyx_obj_3zmq_4core_7context_Context *)values[0]);
    __pyx_v_socket_type = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_socket_type == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
  __Pyx_DECREF(__pyx_v_kwrags); __pyx_v_kwrags = 0;
  __Pyx_AddTraceback("zmq.core.socket.Socket.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_context), __pyx_ptype_3zmq_4core_7context_Context, 1, "context", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "zmq/core/socket.pyx":195
 *     def __cinit__(self, Context context, int socket_type, *args, **kwrags):
 *         cdef Py_ssize_t c_handle
 *         c_handle = context._handle             # <<<<<<<<<<<<<<
 * 
 *         self.handle = NULL
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_context), __pyx_n_s___handle); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_c_handle = __pyx_t_2;

  /* "zmq/core/socket.pyx":197
 *         c_handle = context._handle
 * 
 *         self.handle = NULL             # <<<<<<<<<<<<<<
 *         self.context = context
 *         self.socket_type = socket_type
 */
  ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle = NULL;

  /* "zmq/core/socket.pyx":198
 * 
 *         self.handle = NULL
 *         self.context = context             # <<<<<<<<<<<<<<
 *         self.socket_type = socket_type
 *         with nogil:
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_context));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_context));
  __Pyx_GOTREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context));
  ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context = __pyx_v_context;

  /* "zmq/core/socket.pyx":199
 *         self.handle = NULL
 *         self.context = context
 *         self.socket_type = socket_type             # <<<<<<<<<<<<<<
 *         with nogil:
 *             self.handle = zmq_socket(<void *>c_handle, socket_type)
 */
  ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->socket_type = __pyx_v_socket_type;

  /* "zmq/core/socket.pyx":200
 *         self.context = context
 *         self.socket_type = socket_type
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self.handle = zmq_socket(<void *>c_handle, socket_type)
 *         if self.handle == NULL:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "zmq/core/socket.pyx":201
 *         self.socket_type = socket_type
 *         with nogil:
 *             self.handle = zmq_socket(<void *>c_handle, socket_type)             # <<<<<<<<<<<<<<
 *         if self.handle == NULL:
 *             raise ZMQError()
 */
        ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle = zmq_socket(((void *)__pyx_v_c_handle), __pyx_v_socket_type);
      }

      /* "zmq/core/socket.pyx":200
 *         self.context = context
 *         self.socket_type = socket_type
 *         with nogil:             # <<<<<<<<<<<<<<
 *             self.handle = zmq_socket(<void *>c_handle, socket_type)
 *         if self.handle == NULL:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "zmq/core/socket.pyx":202
 *         with nogil:
 *             self.handle = zmq_socket(<void *>c_handle, socket_type)
 *         if self.handle == NULL:             # <<<<<<<<<<<<<<
 *             raise ZMQError()
 *         self._closed = False
 */
  __pyx_t_3 = (((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle == NULL);
  if (__pyx_t_3) {

    /* "zmq/core/socket.pyx":203
 *             self.handle = zmq_socket(<void *>c_handle, socket_type)
 *         if self.handle == NULL:
 *             raise ZMQError()             # <<<<<<<<<<<<<<
 *         self._closed = False
 *         self._attrs = {}
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "zmq/core/socket.pyx":204
 *         if self.handle == NULL:
 *             raise ZMQError()
 *         self._closed = False             # <<<<<<<<<<<<<<
 *         self._attrs = {}
 *         context._add_socket(self.handle)
 */
  ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->_closed = 0;

  /* "zmq/core/socket.pyx":205
 *             raise ZMQError()
 *         self._closed = False
 *         self._attrs = {}             # <<<<<<<<<<<<<<
 *         context._add_socket(self.handle)
 * 
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __Pyx_GOTREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->_attrs);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->_attrs));
  ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->_attrs = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "zmq/core/socket.pyx":206
 *         self._closed = False
 *         self._attrs = {}
 *         context._add_socket(self.handle)             # <<<<<<<<<<<<<<
 * 
 *     def __del__(self):
 */
  ((struct __pyx_vtabstruct_3zmq_4core_7context_Context *)__pyx_v_context->__pyx_vtab)->_add_socket(__pyx_v_context, ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("zmq.core.socket.Socket.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_kwrags);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":208
 *         context._add_socket(self.handle)
 * 
 *     def __del__(self):             # <<<<<<<<<<<<<<
 *         """close *and* remove from context's list"""
 *         self.close()
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_1__del__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_1__del__[] = "close *and* remove from context's list";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_1__del__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__del__");

  /* "zmq/core/socket.pyx":210
 *     def __del__(self):
 *         """close *and* remove from context's list"""
 *         self.close()             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("zmq.core.socket.Socket.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":212
 *         self.close()
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         """don't touch the Context during dealloc, since it might have been cleaned up already.
 * 
 */

static void __pyx_pf_3zmq_4core_6socket_6Socket_2__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_3zmq_4core_6socket_6Socket_2__dealloc__(PyObject *__pyx_v_self) {
  int __pyx_v_rc;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__dealloc__");

  /* "zmq/core/socket.pyx":216
 * 
 *         This method will likely do nothing unless init has failed."""
 *         if self.handle != NULL:             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 rc = zmq_close(self.handle)
 */
  __pyx_t_1 = (((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle != NULL);
  if (__pyx_t_1) {

    /* "zmq/core/socket.pyx":217
 *         This method will likely do nothing unless init has failed."""
 *         if self.handle != NULL:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 rc = zmq_close(self.handle)
 *             if rc != 0 and zmq_errno() != ENOTSOCK:
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "zmq/core/socket.pyx":218
 *         if self.handle != NULL:
 *             with nogil:
 *                 rc = zmq_close(self.handle)             # <<<<<<<<<<<<<<
 *             if rc != 0 and zmq_errno() != ENOTSOCK:
 *                 # ignore ENOTSOCK (closed by Context)
 */
          __pyx_v_rc = zmq_close(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle);
        }

        /* "zmq/core/socket.pyx":217
 *         This method will likely do nothing unless init has failed."""
 *         if self.handle != NULL:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 rc = zmq_close(self.handle)
 *             if rc != 0 and zmq_errno() != ENOTSOCK:
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }

    /* "zmq/core/socket.pyx":219
 *             with nogil:
 *                 rc = zmq_close(self.handle)
 *             if rc != 0 and zmq_errno() != ENOTSOCK:             # <<<<<<<<<<<<<<
 *                 # ignore ENOTSOCK (closed by Context)
 *                 raise ZMQError()
 */
    __pyx_t_1 = (__pyx_v_rc != 0);
    if (__pyx_t_1) {
      __pyx_t_2 = PyInt_FromLong(zmq_errno()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ENOTSOCK); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_NE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __pyx_t_5;
    } else {
      __pyx_t_6 = __pyx_t_1;
    }
    if (__pyx_t_6) {

      /* "zmq/core/socket.pyx":221
 *             if rc != 0 and zmq_errno() != ENOTSOCK:
 *                 # ignore ENOTSOCK (closed by Context)
 *                 raise ZMQError()             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, context, socket_type):
 */
      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L9;
    }
    __pyx_L9:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("zmq.core.socket.Socket.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "zmq/core/socket.pyx":223
 *                 raise ZMQError()
 * 
 *     def __init__(self, context, socket_type):             # <<<<<<<<<<<<<<
 *         pass
 * 
 */

static int __pyx_pf_3zmq_4core_6socket_6Socket_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_3zmq_4core_6socket_6Socket_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_context = 0;
  PyObject *__pyx_v_socket_type = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__context,&__pyx_n_s__socket_type,0};
  __Pyx_RefNannySetupContext("__init__");
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__context);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__socket_type);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_context = values[0];
    __pyx_v_socket_type = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":227
 * 
 *     @property
 *     def closed(self):             # <<<<<<<<<<<<<<
 *         return _check_closed(self, False)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_4closed(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_4closed(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("closed");

  /* "zmq/core/socket.pyx":228
 *     @property
 *     def closed(self):
 *         return _check_closed(self, False)             # <<<<<<<<<<<<<<
 * 
 *     def close(self, linger=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_3zmq_4core_6socket__check_closed(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("zmq.core.socket.Socket.closed", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":230
 *         return _check_closed(self, False)
 * 
 *     def close(self, linger=None):             # <<<<<<<<<<<<<<
 *         """s.close(linger=None)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_5close(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_5close[] = "s.close(linger=None)\n\n        Close the socket.\n        \n        If linger is specified, LINGER sockopt will be set prior to closing.\n\n        This can be called to close the socket by hand. If this is not\n        called, the socket will automatically be closed when it is\n        garbage collected.\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_5close(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_linger = 0;
  int __pyx_v_rc;
  int __pyx_v_linger_c;
  int __pyx_v_setlinger;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__linger,0};
  __Pyx_RefNannySetupContext("close");
  {
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__linger);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "close") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_linger = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("close", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "zmq/core/socket.pyx":241
 *         garbage collected.
 *         """
 *         cdef int rc=0             # <<<<<<<<<<<<<<
 *         cdef int linger_c
 *         cdef bint setlinger=False
 */
  __pyx_v_rc = 0;

  /* "zmq/core/socket.pyx":243
 *         cdef int rc=0
 *         cdef int linger_c
 *         cdef bint setlinger=False             # <<<<<<<<<<<<<<
 * 
 *         if linger is not None:
 */
  __pyx_v_setlinger = 0;

  /* "zmq/core/socket.pyx":245
 *         cdef bint setlinger=False
 * 
 *         if linger is not None:             # <<<<<<<<<<<<<<
 *             linger_c = linger
 *             setlinger=True
 */
  __pyx_t_1 = (__pyx_v_linger != Py_None);
  if (__pyx_t_1) {

    /* "zmq/core/socket.pyx":246
 * 
 *         if linger is not None:
 *             linger_c = linger             # <<<<<<<<<<<<<<
 *             setlinger=True
 * 
 */
    __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_linger); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_linger_c = __pyx_t_2;

    /* "zmq/core/socket.pyx":247
 *         if linger is not None:
 *             linger_c = linger
 *             setlinger=True             # <<<<<<<<<<<<<<
 * 
 *         if self.handle != NULL and not self._closed:
 */
    __pyx_v_setlinger = 1;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "zmq/core/socket.pyx":249
 *             setlinger=True
 * 
 *         if self.handle != NULL and not self._closed:             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 if setlinger:
 */
  __pyx_t_1 = (((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle != NULL);
  if (__pyx_t_1) {
    __pyx_t_3 = (!((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->_closed);
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_1;
  }
  if (__pyx_t_4) {

    /* "zmq/core/socket.pyx":250
 * 
 *         if self.handle != NULL and not self._closed:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 if setlinger:
 *                     zmq_setsockopt(self.handle, ZMQ_LINGER, &linger_c, sizeof(int))
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "zmq/core/socket.pyx":251
 *         if self.handle != NULL and not self._closed:
 *             with nogil:
 *                 if setlinger:             # <<<<<<<<<<<<<<
 *                     zmq_setsockopt(self.handle, ZMQ_LINGER, &linger_c, sizeof(int))
 *                 rc = zmq_close(self.handle)
 */
          if (__pyx_v_setlinger) {

            /* "zmq/core/socket.pyx":252
 *             with nogil:
 *                 if setlinger:
 *                     zmq_setsockopt(self.handle, ZMQ_LINGER, &linger_c, sizeof(int))             # <<<<<<<<<<<<<<
 *                 rc = zmq_close(self.handle)
 *             if rc != 0 and zmq_errno() != ENOTSOCK:
 */
            zmq_setsockopt(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle, ZMQ_LINGER, (&__pyx_v_linger_c), (sizeof(int)));
            goto __pyx_L11;
          }
          __pyx_L11:;

          /* "zmq/core/socket.pyx":253
 *                 if setlinger:
 *                     zmq_setsockopt(self.handle, ZMQ_LINGER, &linger_c, sizeof(int))
 *                 rc = zmq_close(self.handle)             # <<<<<<<<<<<<<<
 *             if rc != 0 and zmq_errno() != ENOTSOCK:
 *                 # ignore ENOTSOCK (closed by Context)
 */
          __pyx_v_rc = zmq_close(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle);
        }

        /* "zmq/core/socket.pyx":250
 * 
 *         if self.handle != NULL and not self._closed:
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 if setlinger:
 *                     zmq_setsockopt(self.handle, ZMQ_LINGER, &linger_c, sizeof(int))
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }

    /* "zmq/core/socket.pyx":254
 *                     zmq_setsockopt(self.handle, ZMQ_LINGER, &linger_c, sizeof(int))
 *                 rc = zmq_close(self.handle)
 *             if rc != 0 and zmq_errno() != ENOTSOCK:             # <<<<<<<<<<<<<<
 *                 # ignore ENOTSOCK (closed by Context)
 *                 raise ZMQError()
 */
    __pyx_t_4 = (__pyx_v_rc != 0);
    if (__pyx_t_4) {
      __pyx_t_5 = PyInt_FromLong(zmq_errno()); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__ENOTSOCK); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyObject_RichCompare(__pyx_t_5, __pyx_t_6, Py_NE); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_3 = __pyx_t_1;
    } else {
      __pyx_t_3 = __pyx_t_4;
    }
    if (__pyx_t_3) {

      /* "zmq/core/socket.pyx":256
 *             if rc != 0 and zmq_errno() != ENOTSOCK:
 *                 # ignore ENOTSOCK (closed by Context)
 *                 raise ZMQError()             # <<<<<<<<<<<<<<
 *             self.context._remove_socket(self.handle)
 *             self.handle = NULL
 */
      __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L12;
    }
    __pyx_L12:;

    /* "zmq/core/socket.pyx":257
 *                 # ignore ENOTSOCK (closed by Context)
 *                 raise ZMQError()
 *             self.context._remove_socket(self.handle)             # <<<<<<<<<<<<<<
 *             self.handle = NULL
 *             self._closed = True
 */
    ((struct __pyx_vtabstruct_3zmq_4core_7context_Context *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context->__pyx_vtab)->_remove_socket(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context, ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle);

    /* "zmq/core/socket.pyx":258
 *                 raise ZMQError()
 *             self.context._remove_socket(self.handle)
 *             self.handle = NULL             # <<<<<<<<<<<<<<
 *             self._closed = True
 * 
 */
    ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle = NULL;

    /* "zmq/core/socket.pyx":259
 *             self.context._remove_socket(self.handle)
 *             self.handle = NULL
 *             self._closed = True             # <<<<<<<<<<<<<<
 * 
 *     def setsockopt(self, int option, optval):
 */
    ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->_closed = 1;
    goto __pyx_L7;
  }
  __pyx_L7:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("zmq.core.socket.Socket.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":261
 *             self._closed = True
 * 
 *     def setsockopt(self, int option, optval):             # <<<<<<<<<<<<<<
 *         """s.setsockopt(option, optval)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_6setsockopt(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_6setsockopt[] = "s.setsockopt(option, optval)\n\n        Set socket options.\n\n        See the 0MQ API documentation for details on specific options.\n\n        Parameters\n        ----------\n        option : int\n            The option to set.  Available values will depend on your\n            version of libzmq.  Examples include:\n                zmq.SUBSCRIBE, UNSUBSCRIBE, IDENTITY, HWM, LINGER, FD\n        optval : int or bytes\n            The value of the option to set.\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_6setsockopt(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_option;
  PyObject *__pyx_v_optval = 0;
  pyzmq_int64_t __pyx_v_optval_int64_c;
  int __pyx_v_optval_int_c;
  int __pyx_v_rc;
  char *__pyx_v_optval_c;
  Py_ssize_t __pyx_v_sz;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  char *__pyx_t_6;
  Py_ssize_t __pyx_t_7;
  pyzmq_int64_t __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__option,&__pyx_n_s__optval,0};
  __Pyx_RefNannySetupContext("setsockopt");
  {
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__option);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__optval);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("setsockopt", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setsockopt") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_option = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_option == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_optval = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("setsockopt", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.setsockopt", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "zmq/core/socket.pyx":283
 *         cdef Py_ssize_t sz
 * 
 *         _check_closed(self, True)             # <<<<<<<<<<<<<<
 *         if isinstance(optval, unicode):
 *             raise TypeError("unicode not allowed, use setsockopt_unicode")
 */
  __pyx_t_1 = __pyx_f_3zmq_4core_6socket__check_closed(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "zmq/core/socket.pyx":284
 * 
 *         _check_closed(self, True)
 *         if isinstance(optval, unicode):             # <<<<<<<<<<<<<<
 *             raise TypeError("unicode not allowed, use setsockopt_unicode")
 * 
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__unicode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_optval, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "zmq/core/socket.pyx":285
 *         _check_closed(self, True)
 *         if isinstance(optval, unicode):
 *             raise TypeError("unicode not allowed, use setsockopt_unicode")             # <<<<<<<<<<<<<<
 * 
 *         if option in constants.bytes_sockopts:
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "zmq/core/socket.pyx":287
 *             raise TypeError("unicode not allowed, use setsockopt_unicode")
 * 
 *         if option in constants.bytes_sockopts:             # <<<<<<<<<<<<<<
 *             if not isinstance(optval, bytes):
 *                 raise TypeError('expected bytes, got: %r' % optval)
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__constants); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__bytes_sockopts); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = ((PySequence_Contains(__pyx_t_4, __pyx_t_1))); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_2) {

    /* "zmq/core/socket.pyx":288
 * 
 *         if option in constants.bytes_sockopts:
 *             if not isinstance(optval, bytes):             # <<<<<<<<<<<<<<
 *                 raise TypeError('expected bytes, got: %r' % optval)
 *             optval_c = PyBytes_AsString(optval)
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__bytes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyObject_IsInstance(__pyx_v_optval, __pyx_t_4); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = (!__pyx_t_2);
    if (__pyx_t_5) {

      /* "zmq/core/socket.pyx":289
 *         if option in constants.bytes_sockopts:
 *             if not isinstance(optval, bytes):
 *                 raise TypeError('expected bytes, got: %r' % optval)             # <<<<<<<<<<<<<<
 *             optval_c = PyBytes_AsString(optval)
 *             sz = PyBytes_Size(optval)
 */
      __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), __pyx_v_optval); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_4));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "zmq/core/socket.pyx":290
 *             if not isinstance(optval, bytes):
 *                 raise TypeError('expected bytes, got: %r' % optval)
 *             optval_c = PyBytes_AsString(optval)             # <<<<<<<<<<<<<<
 *             sz = PyBytes_Size(optval)
 *             with nogil:
 */
    __pyx_t_6 = PyBytes_AsString(__pyx_v_optval); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_optval_c = __pyx_t_6;

    /* "zmq/core/socket.pyx":291
 *                 raise TypeError('expected bytes, got: %r' % optval)
 *             optval_c = PyBytes_AsString(optval)
 *             sz = PyBytes_Size(optval)             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 rc = zmq_setsockopt(
 */
    __pyx_t_7 = PyBytes_Size(__pyx_v_optval); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_sz = __pyx_t_7;

    /* "zmq/core/socket.pyx":292
 *             optval_c = PyBytes_AsString(optval)
 *             sz = PyBytes_Size(optval)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 rc = zmq_setsockopt(
 *                     self.handle, option,
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "zmq/core/socket.pyx":296
 *                     self.handle, option,
 *                     optval_c, sz
 *                 )             # <<<<<<<<<<<<<<
 *         elif option in constants.int64_sockopts:
 *             if not isinstance(optval, int):
 */
          __pyx_v_rc = zmq_setsockopt(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle, __pyx_v_option, __pyx_v_optval_c, __pyx_v_sz);
        }

        /* "zmq/core/socket.pyx":292
 *             optval_c = PyBytes_AsString(optval)
 *             sz = PyBytes_Size(optval)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 rc = zmq_setsockopt(
 *                     self.handle, option,
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }
    goto __pyx_L7;
  }

  /* "zmq/core/socket.pyx":297
 *                     optval_c, sz
 *                 )
 *         elif option in constants.int64_sockopts:             # <<<<<<<<<<<<<<
 *             if not isinstance(optval, int):
 *                 raise TypeError('expected int, got: %r' % optval)
 */
  __pyx_t_4 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__constants); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__int64_sockopts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = ((PySequence_Contains(__pyx_t_3, __pyx_t_4))); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_5) {

    /* "zmq/core/socket.pyx":298
 *                 )
 *         elif option in constants.int64_sockopts:
 *             if not isinstance(optval, int):             # <<<<<<<<<<<<<<
 *                 raise TypeError('expected int, got: %r' % optval)
 *             optval_int64_c = optval
 */
    __pyx_t_3 = ((PyObject *)((PyObject*)(&PyInt_Type)));
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_TypeCheck(__pyx_v_optval, __pyx_t_3); 
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = (!__pyx_t_5);
    if (__pyx_t_2) {

      /* "zmq/core/socket.pyx":299
 *         elif option in constants.int64_sockopts:
 *             if not isinstance(optval, int):
 *                 raise TypeError('expected int, got: %r' % optval)             # <<<<<<<<<<<<<<
 *             optval_int64_c = optval
 *             with nogil:
 */
      __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), __pyx_v_optval); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L12;
    }
    __pyx_L12:;

    /* "zmq/core/socket.pyx":300
 *             if not isinstance(optval, int):
 *                 raise TypeError('expected int, got: %r' % optval)
 *             optval_int64_c = optval             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 rc = zmq_setsockopt(
 */
    __pyx_t_8 = __Pyx_PyInt_from_py_pyzmq_int64_t(__pyx_v_optval); if (unlikely((__pyx_t_8 == (pyzmq_int64_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_optval_int64_c = __pyx_t_8;

    /* "zmq/core/socket.pyx":301
 *                 raise TypeError('expected int, got: %r' % optval)
 *             optval_int64_c = optval
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 rc = zmq_setsockopt(
 *                     self.handle, option,
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "zmq/core/socket.pyx":304
 *                 rc = zmq_setsockopt(
 *                     self.handle, option,
 *                     &optval_int64_c, sizeof(int64_t)             # <<<<<<<<<<<<<<
 *                 )
 *         else:
 */
          __pyx_v_rc = zmq_setsockopt(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle, __pyx_v_option, (&__pyx_v_optval_int64_c), (sizeof(pyzmq_int64_t)));
        }

        /* "zmq/core/socket.pyx":301
 *                 raise TypeError('expected int, got: %r' % optval)
 *             optval_int64_c = optval
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 rc = zmq_setsockopt(
 *                     self.handle, option,
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }
    goto __pyx_L7;
  }
  /*else*/ {

    /* "zmq/core/socket.pyx":312
 *             # sockopts will still raise just the same, but it will be libzmq doing
 *             # the raising.
 *             if not isinstance(optval, int):             # <<<<<<<<<<<<<<
 *                 raise TypeError('expected int, got: %r' % optval)
 *             optval_int_c = optval
 */
    __pyx_t_3 = ((PyObject *)((PyObject*)(&PyInt_Type)));
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_optval, __pyx_t_3); 
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = (!__pyx_t_2);
    if (__pyx_t_5) {

      /* "zmq/core/socket.pyx":313
 *             # the raising.
 *             if not isinstance(optval, int):
 *                 raise TypeError('expected int, got: %r' % optval)             # <<<<<<<<<<<<<<
 *             optval_int_c = optval
 *             with nogil:
 */
      __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), __pyx_v_optval); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L16;
    }
    __pyx_L16:;

    /* "zmq/core/socket.pyx":314
 *             if not isinstance(optval, int):
 *                 raise TypeError('expected int, got: %r' % optval)
 *             optval_int_c = optval             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 rc = zmq_setsockopt(
 */
    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_v_optval); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_optval_int_c = __pyx_t_9;

    /* "zmq/core/socket.pyx":315
 *                 raise TypeError('expected int, got: %r' % optval)
 *             optval_int_c = optval
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 rc = zmq_setsockopt(
 *                     self.handle, option,
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "zmq/core/socket.pyx":318
 *                 rc = zmq_setsockopt(
 *                     self.handle, option,
 *                     &optval_int_c, sizeof(int)             # <<<<<<<<<<<<<<
 *                 )
 * 
 */
          __pyx_v_rc = zmq_setsockopt(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle, __pyx_v_option, (&__pyx_v_optval_int_c), (sizeof(int)));
        }

        /* "zmq/core/socket.pyx":315
 *                 raise TypeError('expected int, got: %r' % optval)
 *             optval_int_c = optval
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 rc = zmq_setsockopt(
 *                     self.handle, option,
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }
  }
  __pyx_L7:;

  /* "zmq/core/socket.pyx":321
 *                 )
 * 
 *         if rc != 0:             # <<<<<<<<<<<<<<
 *             raise ZMQError()
 * 
 */
  __pyx_t_5 = (__pyx_v_rc != 0);
  if (__pyx_t_5) {

    /* "zmq/core/socket.pyx":322
 * 
 *         if rc != 0:
 *             raise ZMQError()             # <<<<<<<<<<<<<<
 * 
 *     def getsockopt(self, int option):
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L20;
  }
  __pyx_L20:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("zmq.core.socket.Socket.setsockopt", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":324
 *             raise ZMQError()
 * 
 *     def getsockopt(self, int option):             # <<<<<<<<<<<<<<
 *         """s.getsockopt(option)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_7getsockopt(PyObject *__pyx_v_self, PyObject *__pyx_arg_option); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_7getsockopt[] = "s.getsockopt(option)\n\n        Get the value of a socket option.\n\n        See the 0MQ API documentation for details on specific options.\n\n        Parameters\n        ----------\n        option : int\n            The option to get.  Available values will depend on your\n            version of libzmq.  Examples include:\n                zmq.IDENTITY, HWM, LINGER, FD, EVENTS\n\n        Returns\n        -------\n        optval : int or bytes\n            The value of the option as a bytestring or int.\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_7getsockopt(PyObject *__pyx_v_self, PyObject *__pyx_arg_option) {
  int __pyx_v_option;
  pyzmq_int64_t __pyx_v_optval_int64_c;
  int __pyx_v_optval_int_c;
  ZMQ_FD_T __pyx_v_optval_fd_c;
  char __pyx_v_identity_str_c[255];
  size_t __pyx_v_sz;
  int __pyx_v_rc;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getsockopt");
  assert(__pyx_arg_option); {
    __pyx_v_option = __Pyx_PyInt_AsInt(__pyx_arg_option); if (unlikely((__pyx_v_option == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.getsockopt", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "zmq/core/socket.pyx":350
 *         cdef int rc
 * 
 *         _check_closed(self, True)             # <<<<<<<<<<<<<<
 * 
 *         if option in constants.bytes_sockopts:
 */
  __pyx_t_1 = __pyx_f_3zmq_4core_6socket__check_closed(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "zmq/core/socket.pyx":352
 *         _check_closed(self, True)
 * 
 *         if option in constants.bytes_sockopts:             # <<<<<<<<<<<<<<
 *             sz = 255
 *             with nogil:
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__constants); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__bytes_sockopts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = ((PySequence_Contains(__pyx_t_3, __pyx_t_1))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "zmq/core/socket.pyx":353
 * 
 *         if option in constants.bytes_sockopts:
 *             sz = 255             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 rc = zmq_getsockopt(self.handle, option, <void *>identity_str_c, &sz)
 */
    __pyx_v_sz = 255;

    /* "zmq/core/socket.pyx":354
 *         if option in constants.bytes_sockopts:
 *             sz = 255
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 rc = zmq_getsockopt(self.handle, option, <void *>identity_str_c, &sz)
 *             if rc != 0:
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "zmq/core/socket.pyx":355
 *             sz = 255
 *             with nogil:
 *                 rc = zmq_getsockopt(self.handle, option, <void *>identity_str_c, &sz)             # <<<<<<<<<<<<<<
 *             if rc != 0:
 *                 raise ZMQError()
 */
          __pyx_v_rc = zmq_getsockopt(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle, __pyx_v_option, ((void *)__pyx_v_identity_str_c), (&__pyx_v_sz));
        }

        /* "zmq/core/socket.pyx":354
 *         if option in constants.bytes_sockopts:
 *             sz = 255
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 rc = zmq_getsockopt(self.handle, option, <void *>identity_str_c, &sz)
 *             if rc != 0:
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }

    /* "zmq/core/socket.pyx":356
 *             with nogil:
 *                 rc = zmq_getsockopt(self.handle, option, <void *>identity_str_c, &sz)
 *             if rc != 0:             # <<<<<<<<<<<<<<
 *                 raise ZMQError()
 *             result = PyBytes_FromStringAndSize(<char *>identity_str_c, sz)
 */
    __pyx_t_4 = (__pyx_v_rc != 0);
    if (__pyx_t_4) {

      /* "zmq/core/socket.pyx":357
 *                 rc = zmq_getsockopt(self.handle, option, <void *>identity_str_c, &sz)
 *             if rc != 0:
 *                 raise ZMQError()             # <<<<<<<<<<<<<<
 *             result = PyBytes_FromStringAndSize(<char *>identity_str_c, sz)
 *         elif option in  constants.int64_sockopts:
 */
      __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "zmq/core/socket.pyx":358
 *             if rc != 0:
 *                 raise ZMQError()
 *             result = PyBytes_FromStringAndSize(<char *>identity_str_c, sz)             # <<<<<<<<<<<<<<
 *         elif option in  constants.int64_sockopts:
 *             sz = sizeof(int64_t)
 */
    __pyx_t_1 = ((PyObject *)PyBytes_FromStringAndSize(((char *)__pyx_v_identity_str_c), __pyx_v_sz)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_result = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L5;
  }

  /* "zmq/core/socket.pyx":359
 *                 raise ZMQError()
 *             result = PyBytes_FromStringAndSize(<char *>identity_str_c, sz)
 *         elif option in  constants.int64_sockopts:             # <<<<<<<<<<<<<<
 *             sz = sizeof(int64_t)
 *             with nogil:
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__constants); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__int64_sockopts); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = ((PySequence_Contains(__pyx_t_2, __pyx_t_1))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {

    /* "zmq/core/socket.pyx":360
 *             result = PyBytes_FromStringAndSize(<char *>identity_str_c, sz)
 *         elif option in  constants.int64_sockopts:
 *             sz = sizeof(int64_t)             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_int64_c, &sz)
 */
    __pyx_v_sz = (sizeof(pyzmq_int64_t));

    /* "zmq/core/socket.pyx":361
 *         elif option in  constants.int64_sockopts:
 *             sz = sizeof(int64_t)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_int64_c, &sz)
 *             if rc != 0:
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "zmq/core/socket.pyx":362
 *             sz = sizeof(int64_t)
 *             with nogil:
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_int64_c, &sz)             # <<<<<<<<<<<<<<
 *             if rc != 0:
 *                 raise ZMQError()
 */
          __pyx_v_rc = zmq_getsockopt(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle, __pyx_v_option, ((void *)(&__pyx_v_optval_int64_c)), (&__pyx_v_sz));
        }

        /* "zmq/core/socket.pyx":361
 *         elif option in  constants.int64_sockopts:
 *             sz = sizeof(int64_t)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_int64_c, &sz)
 *             if rc != 0:
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }

    /* "zmq/core/socket.pyx":363
 *             with nogil:
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_int64_c, &sz)
 *             if rc != 0:             # <<<<<<<<<<<<<<
 *                 raise ZMQError()
 *             result = optval_int64_c
 */
    __pyx_t_4 = (__pyx_v_rc != 0);
    if (__pyx_t_4) {

      /* "zmq/core/socket.pyx":364
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_int64_c, &sz)
 *             if rc != 0:
 *                 raise ZMQError()             # <<<<<<<<<<<<<<
 *             result = optval_int64_c
 *         elif option == ZMQ_FD:
 */
      __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L13;
    }
    __pyx_L13:;

    /* "zmq/core/socket.pyx":365
 *             if rc != 0:
 *                 raise ZMQError()
 *             result = optval_int64_c             # <<<<<<<<<<<<<<
 *         elif option == ZMQ_FD:
 *             sz = sizeof(fd_t)
 */
    __pyx_t_1 = __Pyx_PyInt_to_py_pyzmq_int64_t(__pyx_v_optval_int64_c); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_result = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L5;
  }

  /* "zmq/core/socket.pyx":366
 *                 raise ZMQError()
 *             result = optval_int64_c
 *         elif option == ZMQ_FD:             # <<<<<<<<<<<<<<
 *             sz = sizeof(fd_t)
 *             with nogil:
 */
  __pyx_t_4 = (__pyx_v_option == ZMQ_FD);
  if (__pyx_t_4) {

    /* "zmq/core/socket.pyx":367
 *             result = optval_int64_c
 *         elif option == ZMQ_FD:
 *             sz = sizeof(fd_t)             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_fd_c, &sz)
 */
    __pyx_v_sz = (sizeof(ZMQ_FD_T));

    /* "zmq/core/socket.pyx":368
 *         elif option == ZMQ_FD:
 *             sz = sizeof(fd_t)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_fd_c, &sz)
 *             if rc != 0:
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "zmq/core/socket.pyx":369
 *             sz = sizeof(fd_t)
 *             with nogil:
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_fd_c, &sz)             # <<<<<<<<<<<<<<
 *             if rc != 0:
 *                 raise ZMQError()
 */
          __pyx_v_rc = zmq_getsockopt(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle, __pyx_v_option, ((void *)(&__pyx_v_optval_fd_c)), (&__pyx_v_sz));
        }

        /* "zmq/core/socket.pyx":368
 *         elif option == ZMQ_FD:
 *             sz = sizeof(fd_t)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_fd_c, &sz)
 *             if rc != 0:
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }

    /* "zmq/core/socket.pyx":370
 *             with nogil:
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_fd_c, &sz)
 *             if rc != 0:             # <<<<<<<<<<<<<<
 *                 raise ZMQError()
 *             result = optval_fd_c
 */
    __pyx_t_4 = (__pyx_v_rc != 0);
    if (__pyx_t_4) {

      /* "zmq/core/socket.pyx":371
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_fd_c, &sz)
 *             if rc != 0:
 *                 raise ZMQError()             # <<<<<<<<<<<<<<
 *             result = optval_fd_c
 *         else:
 */
      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L17;
    }
    __pyx_L17:;

    /* "zmq/core/socket.pyx":372
 *             if rc != 0:
 *                 raise ZMQError()
 *             result = optval_fd_c             # <<<<<<<<<<<<<<
 *         else:
 *             # default is to assume int, which is what most new sockopts will be
 */
    __pyx_t_2 = __Pyx_PyInt_to_py_ZMQ_FD_T(__pyx_v_optval_fd_c); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_result = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "zmq/core/socket.pyx":379
 *             # sockopts will still raise just the same, but it will be libzmq doing
 *             # the raising.
 *             sz = sizeof(int)             # <<<<<<<<<<<<<<
 *             with nogil:
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_int_c, &sz)
 */
    __pyx_v_sz = (sizeof(int));

    /* "zmq/core/socket.pyx":380
 *             # the raising.
 *             sz = sizeof(int)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_int_c, &sz)
 *             if rc != 0:
 */
    {
        #ifdef WITH_THREAD
        PyThreadState *_save = NULL;
        #endif
        Py_UNBLOCK_THREADS
        /*try:*/ {

          /* "zmq/core/socket.pyx":381
 *             sz = sizeof(int)
 *             with nogil:
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_int_c, &sz)             # <<<<<<<<<<<<<<
 *             if rc != 0:
 *                 raise ZMQError()
 */
          __pyx_v_rc = zmq_getsockopt(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle, __pyx_v_option, ((void *)(&__pyx_v_optval_int_c)), (&__pyx_v_sz));
        }

        /* "zmq/core/socket.pyx":380
 *             # the raising.
 *             sz = sizeof(int)
 *             with nogil:             # <<<<<<<<<<<<<<
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_int_c, &sz)
 *             if rc != 0:
 */
        /*finally:*/ {
          Py_BLOCK_THREADS
        }
    }

    /* "zmq/core/socket.pyx":382
 *             with nogil:
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_int_c, &sz)
 *             if rc != 0:             # <<<<<<<<<<<<<<
 *                 raise ZMQError()
 *             result = optval_int_c
 */
    __pyx_t_4 = (__pyx_v_rc != 0);
    if (__pyx_t_4) {

      /* "zmq/core/socket.pyx":383
 *                 rc = zmq_getsockopt(self.handle, option, <void *>&optval_int_c, &sz)
 *             if rc != 0:
 *                 raise ZMQError()             # <<<<<<<<<<<<<<
 *             result = optval_int_c
 * 
 */
      __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L21;
    }
    __pyx_L21:;

    /* "zmq/core/socket.pyx":384
 *             if rc != 0:
 *                 raise ZMQError()
 *             result = optval_int_c             # <<<<<<<<<<<<<<
 * 
 *         return result
 */
    __pyx_t_1 = PyInt_FromLong(__pyx_v_optval_int_c); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_result = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_L5:;

  /* "zmq/core/socket.pyx":386
 *             result = optval_int_c
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def setsockopt_unicode(self, int option, optval, encoding='utf-8'):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("zmq.core.socket.Socket.getsockopt", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":388
 *         return result
 * 
 *     def setsockopt_unicode(self, int option, optval, encoding='utf-8'):             # <<<<<<<<<<<<<<
 *         """s.setsockopt_unicode(option, optval, encoding='utf-8')
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_8setsockopt_unicode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_8setsockopt_unicode[] = "s.setsockopt_unicode(option, optval, encoding='utf-8')\n\n        Set socket options with a unicode object it is simply a wrapper\n        for setsockopt to protect from encoding ambiguity.\n\n        See the 0MQ documentation for details on specific options.\n\n        Parameters\n        ----------\n        option : int\n            The name of the option to set. Can be any of: SUBSCRIBE, \n            UNSUBSCRIBE, IDENTITY\n        optval : unicode\n            The value of the option to set.\n        encoding : str\n            The encoding to be used, default is utf8\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_8setsockopt_unicode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_option;
  PyObject *__pyx_v_optval = 0;
  PyObject *__pyx_v_encoding = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__option,&__pyx_n_s__optval,&__pyx_n_s__encoding,0};
  __Pyx_RefNannySetupContext("setsockopt_unicode");
  {
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)__pyx_kp_s_6);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__option);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__optval);
        if (likely(values[1])) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("setsockopt_unicode", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__encoding);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setsockopt_unicode") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_option = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_option == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_optval = values[1];
    __pyx_v_encoding = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("setsockopt_unicode", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.setsockopt_unicode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "zmq/core/socket.pyx":406
 *             The encoding to be used, default is utf8
 *         """
 *         if not isinstance(optval, unicode):             # <<<<<<<<<<<<<<
 *             raise TypeError("unicode strings only")
 *         return self.setsockopt(option, optval.encode(encoding))
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__unicode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_optval, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (!__pyx_t_2);
  if (__pyx_t_3) {

    /* "zmq/core/socket.pyx":407
 *         """
 *         if not isinstance(optval, unicode):
 *             raise TypeError("unicode strings only")             # <<<<<<<<<<<<<<
 *         return self.setsockopt(option, optval.encode(encoding))
 * 
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "zmq/core/socket.pyx":408
 *         if not isinstance(optval, unicode):
 *             raise TypeError("unicode strings only")
 *         return self.setsockopt(option, optval.encode(encoding))             # <<<<<<<<<<<<<<
 * 
 *     def getsockopt_unicode(self, int option, encoding='utf-8'):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__setsockopt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_GetAttr(__pyx_v_optval, __pyx_n_s__encode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  __Pyx_INCREF(__pyx_v_encoding);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_encoding);
  __Pyx_GIVEREF(__pyx_v_encoding);
  __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_4 = 0;
  __pyx_t_7 = 0;
  __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("zmq.core.socket.Socket.setsockopt_unicode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":410
 *         return self.setsockopt(option, optval.encode(encoding))
 * 
 *     def getsockopt_unicode(self, int option, encoding='utf-8'):             # <<<<<<<<<<<<<<
 *         """s.getsockopt_unicode(option, encoding='utf-8')
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_9getsockopt_unicode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_9getsockopt_unicode[] = "s.getsockopt_unicode(option, encoding='utf-8')\n\n        Get the value of a socket option.\n\n        See the 0MQ documentation for details on specific options.\n\n        Parameters\n        ----------\n        option : int\n            The option to retrieve. Currently, IDENTITY is the only\n            gettable option that can return a string.\n\n        Returns\n        -------\n        optval : unicode\n            The value of the option as a unicode string.\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_9getsockopt_unicode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_option;
  PyObject *__pyx_v_encoding = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__option,&__pyx_n_s__encoding,0};
  __Pyx_RefNannySetupContext("getsockopt_unicode");
  {
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_kp_s_6);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__option);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__encoding);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "getsockopt_unicode") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_option = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_option == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_encoding = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("getsockopt_unicode", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.getsockopt_unicode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "zmq/core/socket.pyx":429
 *         """
 * 
 *         if option not in constants.bytes_sockopts:             # <<<<<<<<<<<<<<
 *             raise TypeError("option %i will not return a string to be decoded"%option)
 *         return self.getsockopt(option).decode(encoding)
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__constants); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__bytes_sockopts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = (__Pyx_NegateNonNeg(PySequence_Contains(__pyx_t_3, __pyx_t_1))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "zmq/core/socket.pyx":430
 * 
 *         if option not in constants.bytes_sockopts:
 *             raise TypeError("option %i will not return a string to be decoded"%option)             # <<<<<<<<<<<<<<
 *         return self.getsockopt(option).decode(encoding)
 * 
 */
    __pyx_t_3 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __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_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "zmq/core/socket.pyx":431
 *         if option not in constants.bytes_sockopts:
 *             raise TypeError("option %i will not return a string to be decoded"%option)
 *         return self.getsockopt(option).decode(encoding)             # <<<<<<<<<<<<<<
 * 
 *     def __setattr__(self, key, value):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__getsockopt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__decode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_v_encoding);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_encoding);
  __Pyx_GIVEREF(__pyx_v_encoding);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("zmq.core.socket.Socket.getsockopt_unicode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":433
 *         return self.getsockopt(option).decode(encoding)
 * 
 *     def __setattr__(self, key, value):             # <<<<<<<<<<<<<<
 *         """set sockopts by attr"""
 *         key = key
 */

static int __pyx_pf_3zmq_4core_6socket_6Socket_10__setattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_10__setattr__[] = "set sockopts by attr";
struct wrapperbase __pyx_wrapperbase_3zmq_4core_6socket_6Socket_10__setattr__;
static int __pyx_pf_3zmq_4core_6socket_6Socket_10__setattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_key, PyObject *__pyx_v_value) {
  PyObject *__pyx_v_opt = NULL;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setattr__");
  __Pyx_INCREF(__pyx_v_key);

  /* "zmq/core/socket.pyx":435
 *     def __setattr__(self, key, value):
 *         """set sockopts by attr"""
 *         key = key             # <<<<<<<<<<<<<<
 *         try:
 *             opt = getattr(constants, key.upper())
 */
  __Pyx_INCREF(__pyx_v_key);
  __Pyx_DECREF(__pyx_v_key);
  __pyx_v_key = __pyx_v_key;

  /* "zmq/core/socket.pyx":436
 *         """set sockopts by attr"""
 *         key = key
 *         try:             # <<<<<<<<<<<<<<
 *             opt = getattr(constants, key.upper())
 *         except AttributeError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "zmq/core/socket.pyx":437
 *         key = key
 *         try:
 *             opt = getattr(constants, key.upper())             # <<<<<<<<<<<<<<
 *         except AttributeError:
 *             # allow subclasses to have extended attributes
 */
      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__constants); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyObject_GetAttr(__pyx_v_key, __pyx_n_s__upper); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L5_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_opt = __pyx_t_5;
      __pyx_t_5 = 0;
    }
    /*else:*/ {

      /* "zmq/core/socket.pyx":445
 *                 raise AttributeError("Socket has no such option: %s"%key.upper())
 *         else:
 *             self.setsockopt(opt, value)             # <<<<<<<<<<<<<<
 * 
 *     def __getattr__(self, key):
 */
      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__setsockopt); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
      __Pyx_INCREF(__pyx_v_opt);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_opt);
      __Pyx_GIVEREF(__pyx_v_opt);
      __Pyx_INCREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L12_try_end;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "zmq/core/socket.pyx":438
 *         try:
 *             opt = getattr(constants, key.upper())
 *         except AttributeError:             # <<<<<<<<<<<<<<
 *             # allow subclasses to have extended attributes
 *             if self.__class__.__module__ != 'zmq.core.socket':
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("zmq.core.socket.Socket.__setattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_5);

      /* "zmq/core/socket.pyx":440
 *         except AttributeError:
 *             # allow subclasses to have extended attributes
 *             if self.__class__.__module__ != 'zmq.core.socket':             # <<<<<<<<<<<<<<
 *                 self._attrs[key] = value
 *             else:
 */
      __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____class__); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s____module__); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_10 = __Pyx_PyString_Equals(__pyx_t_9, ((PyObject *)__pyx_kp_s_10), Py_NE); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (__pyx_t_10) {

        /* "zmq/core/socket.pyx":441
 *             # allow subclasses to have extended attributes
 *             if self.__class__.__module__ != 'zmq.core.socket':
 *                 self._attrs[key] = value             # <<<<<<<<<<<<<<
 *             else:
 *                 raise AttributeError("Socket has no such option: %s"%key.upper())
 */
        if (PyDict_SetItem(((PyObject *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->_attrs), __pyx_v_key, __pyx_v_value) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        goto __pyx_L15;
      }
      /*else*/ {

        /* "zmq/core/socket.pyx":443
 *                 self._attrs[key] = value
 *             else:
 *                 raise AttributeError("Socket has no such option: %s"%key.upper())             # <<<<<<<<<<<<<<
 *         else:
 *             self.setsockopt(opt, value)
 */
        __pyx_t_9 = PyObject_GetAttr(__pyx_v_key, __pyx_n_s__upper); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_8 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_9));
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_8));
        PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_9));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
        __pyx_t_9 = 0;
        __pyx_t_9 = PyObject_Call(__pyx_builtin_AttributeError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
        __Pyx_Raise(__pyx_t_9, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L7_except_error;}
      }
      __pyx_L15:;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L6_exception_handled;
    }
    __pyx_L7_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    __pyx_L12_try_end:;
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("zmq.core.socket.Socket.__setattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_opt);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":447
 *             self.setsockopt(opt, value)
 * 
 *     def __getattr__(self, key):             # <<<<<<<<<<<<<<
 *         """set sockopts by attr"""
 *         if key in self._attrs:
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_11__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_11__getattr__[] = "set sockopts by attr";
struct wrapperbase __pyx_wrapperbase_3zmq_4core_6socket_6Socket_11__getattr__;
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_11__getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
  PyObject *__pyx_v_opt = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__getattr__");
  __Pyx_INCREF(__pyx_v_key);

  /* "zmq/core/socket.pyx":449
 *     def __getattr__(self, key):
 *         """set sockopts by attr"""
 *         if key in self._attrs:             # <<<<<<<<<<<<<<
 *             # `key` is subclass extended attribute
 *             return self._attrs[key]
 */
  if (unlikely(((PyObject *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->_attrs) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_1 = ((PyDict_Contains(((PyObject *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->_attrs), __pyx_v_key))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "zmq/core/socket.pyx":451
 *         if key in self._attrs:
 *             # `key` is subclass extended attribute
 *             return self._attrs[key]             # <<<<<<<<<<<<<<
 *         key = key.upper()
 *         try:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->_attrs), __pyx_v_key); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "zmq/core/socket.pyx":452
 *             # `key` is subclass extended attribute
 *             return self._attrs[key]
 *         key = key.upper()             # <<<<<<<<<<<<<<
 *         try:
 *             opt = getattr(constants, key)
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_key, __pyx_n_s__upper); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_v_key);
  __pyx_v_key = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "zmq/core/socket.pyx":453
 *             return self._attrs[key]
 *         key = key.upper()
 *         try:             # <<<<<<<<<<<<<<
 *             opt = getattr(constants, key)
 *         except AttributeError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "zmq/core/socket.pyx":454
 *         key = key.upper()
 *         try:
 *             opt = getattr(constants, key)             # <<<<<<<<<<<<<<
 *         except AttributeError:
 *             raise AttributeError("Socket has no such option: %s"%key)
 */
      __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__constants); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_v_key); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_opt = __pyx_t_2;
      __pyx_t_2 = 0;
    }
    /*else:*/ {

      /* "zmq/core/socket.pyx":458
 *             raise AttributeError("Socket has no such option: %s"%key)
 *         else:
 *             return self.getsockopt(opt)             # <<<<<<<<<<<<<<
 * 
 *     def bind(self, addr):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__getsockopt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __Pyx_INCREF(__pyx_v_opt);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_opt);
      __Pyx_GIVEREF(__pyx_v_opt);
      __pyx_t_7 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_7;
      __pyx_t_7 = 0;
      goto __pyx_L9_except_return;
    }
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L13_try_end;
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "zmq/core/socket.pyx":455
 *         try:
 *             opt = getattr(constants, key)
 *         except AttributeError:             # <<<<<<<<<<<<<<
 *             raise AttributeError("Socket has no such option: %s"%key)
 *         else:
 */
    __pyx_t_8 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
    if (__pyx_t_8) {
      __Pyx_AddTraceback("zmq.core.socket.Socket.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_3, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_2);

      /* "zmq/core/socket.pyx":456
 *             opt = getattr(constants, key)
 *         except AttributeError:
 *             raise AttributeError("Socket has no such option: %s"%key)             # <<<<<<<<<<<<<<
 *         else:
 *             return self.getsockopt(opt)
 */
      __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), __pyx_v_key); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_9));
      __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_10));
      PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_t_9));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
      __pyx_t_9 = 0;
      __pyx_t_9 = PyObject_Call(__pyx_builtin_AttributeError, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L7_exception_handled;
    }
    __pyx_L8_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L9_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L7_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    __pyx_L13_try_end:;
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("zmq.core.socket.Socket.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_opt);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":460
 *             return self.getsockopt(opt)
 * 
 *     def bind(self, addr):             # <<<<<<<<<<<<<<
 *         """s.bind(addr)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_12bind(PyObject *__pyx_v_self, PyObject *__pyx_v_addr); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_12bind[] = "s.bind(addr)\n\n        Bind the socket to an address.\n\n        This causes the socket to listen on a network port. Sockets on the\n        other side of this connection will use ``Socket.connect(addr)`` to\n        connect to this socket.\n\n        Parameters\n        ----------\n        addr : str\n            The address string. This has the form 'protocol://interface:port',\n            for example 'tcp://127.0.0.1:5555'. Protocols supported are\n            tcp, upd, pgm, inproc and ipc. If the address is unicode, it is\n            encoded to utf-8 first.\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_12bind(PyObject *__pyx_v_self, PyObject *__pyx_v_addr) {
  int __pyx_v_rc;
  char *__pyx_v_c_addr;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  char *__pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("bind");
  __Pyx_INCREF(__pyx_v_addr);

  /* "zmq/core/socket.pyx":480
 *         cdef char* c_addr
 * 
 *         _check_closed(self, True)             # <<<<<<<<<<<<<<
 *         if isinstance(addr, unicode):
 *             addr = addr.encode('utf-8')
 */
  __pyx_t_1 = __pyx_f_3zmq_4core_6socket__check_closed(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "zmq/core/socket.pyx":481
 * 
 *         _check_closed(self, True)
 *         if isinstance(addr, unicode):             # <<<<<<<<<<<<<<
 *             addr = addr.encode('utf-8')
 *         if not isinstance(addr, bytes):
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__unicode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_addr, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "zmq/core/socket.pyx":482
 *         _check_closed(self, True)
 *         if isinstance(addr, unicode):
 *             addr = addr.encode('utf-8')             # <<<<<<<<<<<<<<
 *         if not isinstance(addr, bytes):
 *             raise TypeError('expected str, got: %r' % addr)
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_addr, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_12), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_v_addr);
    __pyx_v_addr = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "zmq/core/socket.pyx":483
 *         if isinstance(addr, unicode):
 *             addr = addr.encode('utf-8')
 *         if not isinstance(addr, bytes):             # <<<<<<<<<<<<<<
 *             raise TypeError('expected str, got: %r' % addr)
 *         c_addr = addr
 */
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__bytes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_addr, __pyx_t_3); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = (!__pyx_t_2);
  if (__pyx_t_4) {

    /* "zmq/core/socket.pyx":484
 *             addr = addr.encode('utf-8')
 *         if not isinstance(addr, bytes):
 *             raise TypeError('expected str, got: %r' % addr)             # <<<<<<<<<<<<<<
 *         c_addr = addr
 *         with nogil:
 */
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_13), __pyx_v_addr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "zmq/core/socket.pyx":485
 *         if not isinstance(addr, bytes):
 *             raise TypeError('expected str, got: %r' % addr)
 *         c_addr = addr             # <<<<<<<<<<<<<<
 *         with nogil:
 *             rc = zmq_bind(self.handle, c_addr)
 */
  __pyx_t_5 = PyBytes_AsString(__pyx_v_addr); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_addr = __pyx_t_5;

  /* "zmq/core/socket.pyx":486
 *             raise TypeError('expected str, got: %r' % addr)
 *         c_addr = addr
 *         with nogil:             # <<<<<<<<<<<<<<
 *             rc = zmq_bind(self.handle, c_addr)
 *         if rc != 0:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "zmq/core/socket.pyx":487
 *         c_addr = addr
 *         with nogil:
 *             rc = zmq_bind(self.handle, c_addr)             # <<<<<<<<<<<<<<
 *         if rc != 0:
 *             raise ZMQError()
 */
        __pyx_v_rc = zmq_bind(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle, __pyx_v_c_addr);
      }

      /* "zmq/core/socket.pyx":486
 *             raise TypeError('expected str, got: %r' % addr)
 *         c_addr = addr
 *         with nogil:             # <<<<<<<<<<<<<<
 *             rc = zmq_bind(self.handle, c_addr)
 *         if rc != 0:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "zmq/core/socket.pyx":488
 *         with nogil:
 *             rc = zmq_bind(self.handle, c_addr)
 *         if rc != 0:             # <<<<<<<<<<<<<<
 *             raise ZMQError()
 * 
 */
  __pyx_t_4 = (__pyx_v_rc != 0);
  if (__pyx_t_4) {

    /* "zmq/core/socket.pyx":489
 *             rc = zmq_bind(self.handle, c_addr)
 *         if rc != 0:
 *             raise ZMQError()             # <<<<<<<<<<<<<<
 * 
 *     def bind_to_random_port(self, addr, min_port=49152, max_port=65536, max_tries=100):
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L10;
  }
  __pyx_L10:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("zmq.core.socket.Socket.bind", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_addr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":491
 *             raise ZMQError()
 * 
 *     def bind_to_random_port(self, addr, min_port=49152, max_port=65536, max_tries=100):             # <<<<<<<<<<<<<<
 *         """s.bind_to_random_port(addr, min_port=49152, max_port=65536, max_tries=100)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_13bind_to_random_port(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_13bind_to_random_port[] = "s.bind_to_random_port(addr, min_port=49152, max_port=65536, max_tries=100)\n\n        Bind this socket to a random port in a range.\n\n        Parameters\n        ----------\n        addr : str\n            The address string without the port to pass to ``Socket.bind()``.\n        min_port : int, optional\n            The minimum port in the range of ports to try (inclusive).\n        max_port : int, optional\n            The maximum port in the range of ports to try (exclusive).\n        max_tries : int, optional\n            The maximum number of bind attempts to make.\n\n        Returns\n        -------\n        port : int\n            The port the socket was bound to.\n        \n        Raises\n        ------\n        ZMQBindError\n            if `max_tries` reached before successful bind\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_13bind_to_random_port(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_addr = 0;
  PyObject *__pyx_v_min_port = 0;
  PyObject *__pyx_v_max_port = 0;
  PyObject *__pyx_v_max_tries = 0;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_port = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__addr,&__pyx_n_s__min_port,&__pyx_n_s__max_port,&__pyx_n_s__max_tries,0};
  __Pyx_RefNannySetupContext("bind_to_random_port");
  {
    PyObject* values[4] = {0,0,0,0};
    values[1] = ((PyObject *)__pyx_int_49152);
    values[2] = ((PyObject *)__pyx_int_65536);
    values[3] = ((PyObject *)__pyx_int_100);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__addr);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__min_port);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_port);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_tries);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "bind_to_random_port") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_addr = values[0];
    __pyx_v_min_port = values[1];
    __pyx_v_max_port = values[2];
    __pyx_v_max_tries = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("bind_to_random_port", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.bind_to_random_port", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "zmq/core/socket.pyx":517
 *             if `max_tries` reached before successful bind
 *         """
 *         for i in xrange(max_tries):             # <<<<<<<<<<<<<<
 *             try:
 *                 port = random.randrange(min_port, max_port)
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_v_max_tries);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_max_tries);
  __Pyx_GIVEREF(__pyx_v_max_tries);
  __pyx_t_2 = PyObject_Call(__pyx_builtin_xrange, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
    } else if (PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "zmq/core/socket.pyx":518
 *         """
 *         for i in xrange(max_tries):
 *             try:             # <<<<<<<<<<<<<<
 *                 port = random.randrange(min_port, max_port)
 *                 self.bind('%s:%s' % (addr, port))
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      /*try:*/ {

        /* "zmq/core/socket.pyx":519
 *         for i in xrange(max_tries):
 *             try:
 *                 port = random.randrange(min_port, max_port)             # <<<<<<<<<<<<<<
 *                 self.bind('%s:%s' % (addr, port))
 *             except ZMQError:
 */
        __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__random); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_8 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__randrange); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
        __Pyx_INCREF(__pyx_v_min_port);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_min_port);
        __Pyx_GIVEREF(__pyx_v_min_port);
        __Pyx_INCREF(__pyx_v_max_port);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_max_port);
        __Pyx_GIVEREF(__pyx_v_max_port);
        __pyx_t_9 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_v_port);
        __pyx_v_port = __pyx_t_9;
        __pyx_t_9 = 0;

        /* "zmq/core/socket.pyx":520
 *             try:
 *                 port = random.randrange(min_port, max_port)
 *                 self.bind('%s:%s' % (addr, port))             # <<<<<<<<<<<<<<
 *             except ZMQError:
 *                 pass
 */
        __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__bind); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
        __Pyx_INCREF(__pyx_v_addr);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_addr);
        __Pyx_GIVEREF(__pyx_v_addr);
        __Pyx_INCREF(__pyx_v_port);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_port);
        __Pyx_GIVEREF(__pyx_v_port);
        __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_14), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_8));
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
        PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_8));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
        __pyx_t_8 = 0;
        __pyx_t_8 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
      /*else:*/ {

        /* "zmq/core/socket.pyx":524
 *                 pass
 *             else:
 *                 return port             # <<<<<<<<<<<<<<
 *         raise ZMQBindError("Could not bind socket to random port.")
 * 
 */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_v_port);
        __pyx_r = __pyx_v_port;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L11_except_return;
      }
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L15_try_end;
      __pyx_L8_error:;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "zmq/core/socket.pyx":521
 *                 port = random.randrange(min_port, max_port)
 *                 self.bind('%s:%s' % (addr, port))
 *             except ZMQError:             # <<<<<<<<<<<<<<
 *                 pass
 *             else:
 */
      __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_10 = PyErr_ExceptionMatches(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (__pyx_t_10) {
        PyErr_Restore(0,0,0);
        goto __pyx_L9_exception_handled;
      }
      __pyx_L10_except_error:;
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
      goto __pyx_L1_error;
      __pyx_L11_except_return:;
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
      goto __pyx_L0;
      __pyx_L9_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
      __pyx_L15_try_end:;
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "zmq/core/socket.pyx":525
 *             else:
 *                 return port
 *         raise ZMQBindError("Could not bind socket to random port.")             # <<<<<<<<<<<<<<
 * 
 *     def connect(self, addr):
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQBindError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_16), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_Raise(__pyx_t_8, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("zmq.core.socket.Socket.bind_to_random_port", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_port);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":527
 *         raise ZMQBindError("Could not bind socket to random port.")
 * 
 *     def connect(self, addr):             # <<<<<<<<<<<<<<
 *         """s.connect(addr)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_14connect(PyObject *__pyx_v_self, PyObject *__pyx_v_addr); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_14connect[] = "s.connect(addr)\n\n        Connect to a remote 0MQ socket.\n\n        Parameters\n        ----------\n        addr : str\n            The address string. This has the form 'protocol://interface:port',\n            for example 'tcp://127.0.0.1:5555'. Protocols supported are\n            tcp, upd, pgm, inproc and ipc. If the address is unicode, it is\n            encoded to utf-8 first.\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_14connect(PyObject *__pyx_v_self, PyObject *__pyx_v_addr) {
  int __pyx_v_rc;
  char *__pyx_v_c_addr;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  char *__pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("connect");
  __Pyx_INCREF(__pyx_v_addr);

  /* "zmq/core/socket.pyx":543
 *         cdef char* c_addr
 * 
 *         _check_closed(self, True)             # <<<<<<<<<<<<<<
 *         if isinstance(addr, unicode):
 *             addr = addr.encode('utf-8')
 */
  __pyx_t_1 = __pyx_f_3zmq_4core_6socket__check_closed(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "zmq/core/socket.pyx":544
 * 
 *         _check_closed(self, True)
 *         if isinstance(addr, unicode):             # <<<<<<<<<<<<<<
 *             addr = addr.encode('utf-8')
 *         if not isinstance(addr, bytes):
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__unicode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_addr, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "zmq/core/socket.pyx":545
 *         _check_closed(self, True)
 *         if isinstance(addr, unicode):
 *             addr = addr.encode('utf-8')             # <<<<<<<<<<<<<<
 *         if not isinstance(addr, bytes):
 *             raise TypeError('expected str, got: %r' % addr)
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_addr, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_17), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_v_addr);
    __pyx_v_addr = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "zmq/core/socket.pyx":546
 *         if isinstance(addr, unicode):
 *             addr = addr.encode('utf-8')
 *         if not isinstance(addr, bytes):             # <<<<<<<<<<<<<<
 *             raise TypeError('expected str, got: %r' % addr)
 *         c_addr = addr
 */
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__bytes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_addr, __pyx_t_3); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = (!__pyx_t_2);
  if (__pyx_t_4) {

    /* "zmq/core/socket.pyx":547
 *             addr = addr.encode('utf-8')
 *         if not isinstance(addr, bytes):
 *             raise TypeError('expected str, got: %r' % addr)             # <<<<<<<<<<<<<<
 *         c_addr = addr
 * 
 */
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_13), __pyx_v_addr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "zmq/core/socket.pyx":548
 *         if not isinstance(addr, bytes):
 *             raise TypeError('expected str, got: %r' % addr)
 *         c_addr = addr             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
  __pyx_t_5 = PyBytes_AsString(__pyx_v_addr); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_c_addr = __pyx_t_5;

  /* "zmq/core/socket.pyx":550
 *         c_addr = addr
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             rc = zmq_connect(self.handle, c_addr)
 *         if rc != 0:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save = NULL;
      #endif
      Py_UNBLOCK_THREADS
      /*try:*/ {

        /* "zmq/core/socket.pyx":551
 * 
 *         with nogil:
 *             rc = zmq_connect(self.handle, c_addr)             # <<<<<<<<<<<<<<
 *         if rc != 0:
 *             raise ZMQError()
 */
        __pyx_v_rc = zmq_connect(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle, __pyx_v_c_addr);
      }

      /* "zmq/core/socket.pyx":550
 *         c_addr = addr
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             rc = zmq_connect(self.handle, c_addr)
 *         if rc != 0:
 */
      /*finally:*/ {
        Py_BLOCK_THREADS
      }
  }

  /* "zmq/core/socket.pyx":552
 *         with nogil:
 *             rc = zmq_connect(self.handle, c_addr)
 *         if rc != 0:             # <<<<<<<<<<<<<<
 *             raise ZMQError()
 * 
 */
  __pyx_t_4 = (__pyx_v_rc != 0);
  if (__pyx_t_4) {

    /* "zmq/core/socket.pyx":553
 *             rc = zmq_connect(self.handle, c_addr)
 *         if rc != 0:
 *             raise ZMQError()             # <<<<<<<<<<<<<<
 * 
 *     #-------------------------------------------------------------------------
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L10;
  }
  __pyx_L10:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("zmq.core.socket.Socket.connect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_addr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":559
 *     #-------------------------------------------------------------------------
 * 
 *     cpdef object send(self, object data, int flags=0, copy=True, track=False):             # <<<<<<<<<<<<<<
 *         """s.send(data, flags=0, copy=True, track=False)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_15send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3zmq_4core_6socket_6Socket_send(struct __pyx_obj_3zmq_4core_6socket_Socket *__pyx_v_self, PyObject *__pyx_v_data, int __pyx_skip_dispatch, struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send *__pyx_optional_args) {
  int __pyx_v_flags = ((int)0);
  PyObject *__pyx_v_copy = __pyx_k_18;
  PyObject *__pyx_v_track = __pyx_k_19;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  struct __pyx_opt_args_3zmq_4core_6socket__send_copy __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  struct __pyx_opt_args_3zmq_4core_6socket__send_message __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("send");
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_flags = __pyx_optional_args->flags;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_copy = __pyx_optional_args->copy;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_track = __pyx_optional_args->track;
        }
      }
    }
  }
  __Pyx_INCREF(__pyx_v_data);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__send); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_3zmq_4core_6socket_6Socket_15send)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __Pyx_INCREF(__pyx_v_data);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_data);
      __Pyx_GIVEREF(__pyx_v_data);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_copy);
      PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_copy);
      __Pyx_GIVEREF(__pyx_v_copy);
      __Pyx_INCREF(__pyx_v_track);
      PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_track);
      __Pyx_GIVEREF(__pyx_v_track);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "zmq/core/socket.pyx":596
 * 
 *         """
 *         _check_closed(self, True)             # <<<<<<<<<<<<<<
 * 
 *         if isinstance(data, unicode):
 */
  __pyx_t_1 = __pyx_f_3zmq_4core_6socket__check_closed(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "zmq/core/socket.pyx":598
 *         _check_closed(self, True)
 * 
 *         if isinstance(data, unicode):             # <<<<<<<<<<<<<<
 *             raise TypeError("unicode not allowed, use send_unicode")
 * 
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__unicode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_IsInstance(__pyx_v_data, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {

    /* "zmq/core/socket.pyx":599
 * 
 *         if isinstance(data, unicode):
 *             raise TypeError("unicode not allowed, use send_unicode")             # <<<<<<<<<<<<<<
 * 
 *         if copy:
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_21), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "zmq/core/socket.pyx":601
 *             raise TypeError("unicode not allowed, use send_unicode")
 * 
 *         if copy:             # <<<<<<<<<<<<<<
 *             # msg.bytes never returns the input data object
 *             # it is always a copy, but always the same copy
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_copy); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_4) {

    /* "zmq/core/socket.pyx":604
 *             # msg.bytes never returns the input data object
 *             # it is always a copy, but always the same copy
 *             if isinstance(data, Message):             # <<<<<<<<<<<<<<
 *                 data = data.buffer
 *             return _send_copy(self.handle, data, flags)
 */
    __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_3zmq_4core_7message_Message));
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_TypeCheck(__pyx_v_data, __pyx_t_1); 
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_4) {

      /* "zmq/core/socket.pyx":605
 *             # it is always a copy, but always the same copy
 *             if isinstance(data, Message):
 *                 data = data.buffer             # <<<<<<<<<<<<<<
 *             return _send_copy(self.handle, data, flags)
 *         else:
 */
      __pyx_t_1 = PyObject_GetAttr(__pyx_v_data, __pyx_n_s__buffer); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_v_data);
      __pyx_v_data = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "zmq/core/socket.pyx":606
 *             if isinstance(data, Message):
 *                 data = data.buffer
 *             return _send_copy(self.handle, data, flags)             # <<<<<<<<<<<<<<
 *         else:
 *             if isinstance(data, Message):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5.__pyx_n = 1;
    __pyx_t_5.flags = __pyx_v_flags;
    __pyx_t_1 = __pyx_f_3zmq_4core_6socket__send_copy(__pyx_v_self->handle, __pyx_v_data, &__pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "zmq/core/socket.pyx":608
 *             return _send_copy(self.handle, data, flags)
 *         else:
 *             if isinstance(data, Message):             # <<<<<<<<<<<<<<
 *                 if track and not data.tracker:
 *                     raise ValueError('Not a tracked message')
 */
    __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_3zmq_4core_7message_Message));
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_TypeCheck(__pyx_v_data, __pyx_t_1); 
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_4) {

      /* "zmq/core/socket.pyx":609
 *         else:
 *             if isinstance(data, Message):
 *                 if track and not data.tracker:             # <<<<<<<<<<<<<<
 *                     raise ValueError('Not a tracked message')
 *                 msg = data
 */
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_track); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (__pyx_t_4) {
        __pyx_t_1 = PyObject_GetAttr(__pyx_v_data, __pyx_n_s__tracker); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_7 = (!__pyx_t_6);
        __pyx_t_6 = __pyx_t_7;
      } else {
        __pyx_t_6 = __pyx_t_4;
      }
      if (__pyx_t_6) {

        /* "zmq/core/socket.pyx":610
 *             if isinstance(data, Message):
 *                 if track and not data.tracker:
 *                     raise ValueError('Not a tracked message')             # <<<<<<<<<<<<<<
 *                 msg = data
 *             else:
 */
        __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_23), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L7;
      }
      __pyx_L7:;

      /* "zmq/core/socket.pyx":611
 *                 if track and not data.tracker:
 *                     raise ValueError('Not a tracked message')
 *                 msg = data             # <<<<<<<<<<<<<<
 *             else:
 *                 msg = Message(data, track=track)
 */
      __Pyx_INCREF(__pyx_v_data);
      __pyx_v_msg = __pyx_v_data;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "zmq/core/socket.pyx":613
 *                 msg = data
 *             else:
 *                 msg = Message(data, track=track)             # <<<<<<<<<<<<<<
 *             return _send_message(self.handle, msg, flags)
 * 
 */
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
      __Pyx_INCREF(__pyx_v_data);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_data);
      __Pyx_GIVEREF(__pyx_v_data);
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__track), __pyx_v_track) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_3zmq_4core_7message_Message)), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_v_msg = __pyx_t_3;
      __pyx_t_3 = 0;
    }
    __pyx_L6:;

    /* "zmq/core/socket.pyx":614
 *             else:
 *                 msg = Message(data, track=track)
 *             return _send_message(self.handle, msg, flags)             # <<<<<<<<<<<<<<
 * 
 *     cpdef object recv(self, int flags=0, copy=True, track=False):
 */
    __Pyx_XDECREF(__pyx_r);
    if (!(likely(((__pyx_v_msg) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_msg, __pyx_ptype_3zmq_4core_7message_Message))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = __pyx_v_msg;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_8.__pyx_n = 1;
    __pyx_t_8.flags = __pyx_v_flags;
    __pyx_t_2 = __pyx_f_3zmq_4core_6socket__send_message(__pyx_v_self->handle, ((struct __pyx_obj_3zmq_4core_7message_Message *)__pyx_t_3), &__pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }
  __pyx_L4:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("zmq.core.socket.Socket.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":559
 *     #-------------------------------------------------------------------------
 * 
 *     cpdef object send(self, object data, int flags=0, copy=True, track=False):             # <<<<<<<<<<<<<<
 *         """s.send(data, flags=0, copy=True, track=False)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_15send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_15send[] = "s.send(data, flags=0, copy=True, track=False)\n\n        Send a message on this socket.\n\n        This queues the message to be sent by the IO thread at a later time.\n\n        Parameters\n        ----------\n        data : object, str, Message\n            The content of the message.\n        flags : int\n            Any supported flag: NOBLOCK, SNDMORE.\n        copy : bool\n            Should the message be sent in a copying or non-copying manner.\n        track : bool\n            Should the message be tracked for notification that ZMQ has\n            finished with it? (ignored if copy=True)\n\n        Returns\n        -------\n        None : if `copy` or not track\n            None if message was sent, raises an exception otherwise.\n        MessageTracker : if track and not copy\n            a MessageTracker object, whose `pending` property will\n            be True until the send is completed.\n        \n        Raises\n        ------\n        TypeError\n            If a unicode object is passed\n        ValueError\n            If `track=True`, but an untracked Message is passed.\n        ZMQError\n            If the send does not succeed for any reason.\n        \n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_15send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_data = 0;
  int __pyx_v_flags;
  PyObject *__pyx_v_copy = 0;
  PyObject *__pyx_v_track = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__data,&__pyx_n_s__flags,&__pyx_n_s__copy,&__pyx_n_s__track,0};
  __Pyx_RefNannySetupContext("send");
  {
    PyObject* values[4] = {0,0,0,0};
    values[2] = __pyx_k_18;
    values[3] = __pyx_k_19;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__data);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__copy);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "send") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_data = values[0];
    if (values[1]) {
      __pyx_v_flags = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_flags = ((int)0);
    }
    __pyx_v_copy = values[2];
    __pyx_v_track = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("send", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.flags = __pyx_v_flags;
  __pyx_t_2.copy = __pyx_v_copy;
  __pyx_t_2.track = __pyx_v_track;
  __pyx_t_1 = ((struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->__pyx_vtab)->send(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), __pyx_v_data, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("zmq.core.socket.Socket.send", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":616
 *             return _send_message(self.handle, msg, flags)
 * 
 *     cpdef object recv(self, int flags=0, copy=True, track=False):             # <<<<<<<<<<<<<<
 *         """s.recv(flags=0, copy=True, track=False)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_16recv(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_3zmq_4core_6socket_6Socket_recv(struct __pyx_obj_3zmq_4core_6socket_Socket *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv *__pyx_optional_args) {
  int __pyx_v_flags = ((int)0);
  PyObject *__pyx_v_copy = __pyx_k_24;
  PyObject *__pyx_v_track = __pyx_k_25;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  struct __pyx_opt_args_3zmq_4core_6socket__recv_copy __pyx_t_5;
  struct __pyx_opt_args_3zmq_4core_6socket__recv_message __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("recv");
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_flags = __pyx_optional_args->flags;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_copy = __pyx_optional_args->copy;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_track = __pyx_optional_args->track;
        }
      }
    }
  }
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__recv); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_3zmq_4core_6socket_6Socket_16recv)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_copy);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_copy);
      __Pyx_GIVEREF(__pyx_v_copy);
      __Pyx_INCREF(__pyx_v_track);
      PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_track);
      __Pyx_GIVEREF(__pyx_v_track);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "zmq/core/socket.pyx":647
 *             for any of the reasons zmq_recvmsg might fail.
 *         """
 *         _check_closed(self, True)             # <<<<<<<<<<<<<<
 * 
 *         if copy:
 */
  __pyx_t_1 = __pyx_f_3zmq_4core_6socket__check_closed(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "zmq/core/socket.pyx":649
 *         _check_closed(self, True)
 * 
 *         if copy:             # <<<<<<<<<<<<<<
 *             return _recv_copy(self.handle, flags)
 *         else:
 */
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_copy); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_4) {

    /* "zmq/core/socket.pyx":650
 * 
 *         if copy:
 *             return _recv_copy(self.handle, flags)             # <<<<<<<<<<<<<<
 *         else:
 *             return _recv_message(self.handle, flags, track)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5.__pyx_n = 1;
    __pyx_t_5.flags = __pyx_v_flags;
    __pyx_t_1 = __pyx_f_3zmq_4core_6socket__recv_copy(__pyx_v_self->handle, &__pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "zmq/core/socket.pyx":652
 *             return _recv_copy(self.handle, flags)
 *         else:
 *             return _recv_message(self.handle, flags, track)             # <<<<<<<<<<<<<<
 * 
 *     def send_multipart(self, msg_parts, int flags=0, copy=True, track=False, prefix=None):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6.__pyx_n = 2;
    __pyx_t_6.flags = __pyx_v_flags;
    __pyx_t_6.track = __pyx_v_track;
    __pyx_t_1 = ((PyObject *)__pyx_f_3zmq_4core_6socket__recv_message(__pyx_v_self->handle, &__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("zmq.core.socket.Socket.recv", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":616
 *             return _send_message(self.handle, msg, flags)
 * 
 *     cpdef object recv(self, int flags=0, copy=True, track=False):             # <<<<<<<<<<<<<<
 *         """s.recv(flags=0, copy=True, track=False)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_16recv(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_16recv[] = "s.recv(flags=0, copy=True, track=False)\n\n        Receive a message.\n\n        Parameters\n        ----------\n        flags : int\n            Any supported flag: NOBLOCK. If NOBLOCK is set, this method\n            will raise a ZMQError with EAGAIN if a message is not ready.\n            If NOBLOCK is not set, then this method will block until a\n            message arrives.\n        copy : bool\n            Should the message be received in a copying or non-copying manner?\n            If False a Message object is returned, if True a string copy of\n            message is returned.\n        track : bool\n            Should the message be tracked for notification that ZMQ has\n            finished with it? (ignored if copy=True)\n\n        Returns\n        -------\n        msg : str, Message\n            The returned message.  If `copy` is False, then it will be a Message,\n            otherwise a str.\n            \n        Raises\n        ------\n        ZMQError\n            for any of the reasons zmq_recvmsg might fail.\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_16recv(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_flags;
  PyObject *__pyx_v_copy = 0;
  PyObject *__pyx_v_track = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__flags,&__pyx_n_s__copy,&__pyx_n_s__track,0};
  __Pyx_RefNannySetupContext("recv");
  {
    PyObject* values[3] = {0,0,0};
    values[1] = __pyx_k_24;
    values[2] = __pyx_k_25;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__copy);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "recv") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_flags = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_flags = ((int)0);
    }
    __pyx_v_copy = values[1];
    __pyx_v_track = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("recv", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.recv", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 3;
  __pyx_t_2.flags = __pyx_v_flags;
  __pyx_t_2.copy = __pyx_v_copy;
  __pyx_t_2.track = __pyx_v_track;
  __pyx_t_1 = ((struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->__pyx_vtab)->recv(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("zmq.core.socket.Socket.recv", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":654
 *             return _recv_message(self.handle, flags, track)
 * 
 *     def send_multipart(self, msg_parts, int flags=0, copy=True, track=False, prefix=None):             # <<<<<<<<<<<<<<
 *         """s.send_multipart(msg_parts, flags=0, copy=True, track=False, prefix=None)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_17send_multipart(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_17send_multipart[] = "s.send_multipart(msg_parts, flags=0, copy=True, track=False, prefix=None)\n\n        Send a sequence of messages as a multipart message.\n\n        Parameters\n        ----------\n        msg_parts : iterable\n            A sequence of messages to send as a multipart message. Each element\n            can be any sendable object (Message, bytes, buffer-providers)\n        flags : int, optional\n            Only the NOBLOCK flagis supported, SNDMORE is handled\n            automatically.\n        copy : bool, optional\n            Should the message(s) be sent in a copying or non-copying manner.\n        track : bool, optional\n            Should the message(s) be tracked for notification that ZMQ has\n            finished with it (ignored if copy=True).\n        prefix : iterable\n            A sequence of messages to send as a 0MQ routing prefix. With the removal\n            of LABELs from libzmq3, `prefix` has no effect beyond being prepended\n            to msg_parts.\n        \n        Returns\n        -------\n        None : if copy or not track\n        MessageTracker : if track and not copy\n            a MessageTracker object, whose `pending` property will\n            be True until the last send is completed.\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_17send_multipart(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_msg_parts = 0;
  int __pyx_v_flags;
  PyObject *__pyx_v_copy = 0;
  PyObject *__pyx_v_track = 0;
  PyObject *__pyx_v_prefix = 0;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__msg_parts,&__pyx_n_s__flags,&__pyx_n_s__copy,&__pyx_n_s__track,&__pyx_n_s__prefix,0};
  __Pyx_RefNannySetupContext("send_multipart");
  {
    PyObject* values[5] = {0,0,0,0,0};
    values[2] = __pyx_k_26;
    values[3] = __pyx_k_27;
    values[4] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__msg_parts);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__copy);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__prefix);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "send_multipart") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_msg_parts = values[0];
    if (values[1]) {
      __pyx_v_flags = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_flags = ((int)0);
    }
    __pyx_v_copy = values[2];
    __pyx_v_track = values[3];
    __pyx_v_prefix = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("send_multipart", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.send_multipart", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF(__pyx_v_prefix);

  /* "zmq/core/socket.pyx":684
 *             be True until the last send is completed.
 *         """
 *         if prefix:             # <<<<<<<<<<<<<<
 *             if isinstance(prefix, bytes):
 *                 prefix = [prefix]
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_prefix); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "zmq/core/socket.pyx":685
 *         """
 *         if prefix:
 *             if isinstance(prefix, bytes):             # <<<<<<<<<<<<<<
 *                 prefix = [prefix]
 *             for msg in prefix:
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__bytes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_IsInstance(__pyx_v_prefix, __pyx_t_2); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_1) {

      /* "zmq/core/socket.pyx":686
 *         if prefix:
 *             if isinstance(prefix, bytes):
 *                 prefix = [prefix]             # <<<<<<<<<<<<<<
 *             for msg in prefix:
 *                 self.send(msg, SNDMORE|flags)
 */
      __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_prefix);
      PyList_SET_ITEM(__pyx_t_2, 0, __pyx_v_prefix);
      __Pyx_GIVEREF(__pyx_v_prefix);
      __Pyx_DECREF(__pyx_v_prefix);
      __pyx_v_prefix = ((PyObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "zmq/core/socket.pyx":687
 *             if isinstance(prefix, bytes):
 *                 prefix = [prefix]
 *             for msg in prefix:             # <<<<<<<<<<<<<<
 *                 self.send(msg, SNDMORE|flags)
 *         for msg in msg_parts[:-1]:
 */
    if (PyList_CheckExact(__pyx_v_prefix) || PyTuple_CheckExact(__pyx_v_prefix)) {
      __pyx_t_2 = __pyx_v_prefix; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
      __pyx_t_4 = NULL;
    } else {
      __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_prefix); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
    }
    for (;;) {
      if (PyList_CheckExact(__pyx_t_2)) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++;
      } else if (PyTuple_CheckExact(__pyx_t_2)) {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++;
      } else {
        __pyx_t_5 = __pyx_t_4(__pyx_t_2);
        if (unlikely(!__pyx_t_5)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_XDECREF(__pyx_v_msg);
      __pyx_v_msg = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "zmq/core/socket.pyx":688
 *                 prefix = [prefix]
 *             for msg in prefix:
 *                 self.send(msg, SNDMORE|flags)             # <<<<<<<<<<<<<<
 *         for msg in msg_parts[:-1]:
 *             self.send(msg, SNDMORE|flags, copy=copy, track=track)
 */
      __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__SNDMORE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyNumber_Or(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_9.__pyx_n = 1;
      __pyx_t_9.flags = __pyx_t_8;
      __pyx_t_7 = ((struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->__pyx_vtab)->send(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), __pyx_v_msg, 0, &__pyx_t_9); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "zmq/core/socket.pyx":689
 *             for msg in prefix:
 *                 self.send(msg, SNDMORE|flags)
 *         for msg in msg_parts[:-1]:             # <<<<<<<<<<<<<<
 *             self.send(msg, SNDMORE|flags, copy=copy, track=track)
 *         # Send the last part without the extra SNDMORE flag.
 */
  __pyx_t_2 = __Pyx_PySequence_GetSlice(__pyx_v_msg_parts, 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_7 = __pyx_t_2; __Pyx_INCREF(__pyx_t_7); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = Py_TYPE(__pyx_t_7)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (PyList_CheckExact(__pyx_t_7)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_7)) break;
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
    } else if (PyTuple_CheckExact(__pyx_t_7)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++;
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_7);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF(__pyx_v_msg);
    __pyx_v_msg = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "zmq/core/socket.pyx":690
 *                 self.send(msg, SNDMORE|flags)
 *         for msg in msg_parts[:-1]:
 *             self.send(msg, SNDMORE|flags, copy=copy, track=track)             # <<<<<<<<<<<<<<
 *         # Send the last part without the extra SNDMORE flag.
 *         return self.send(msg_parts[-1], flags, copy=copy, track=track)
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__send); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__SNDMORE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_10 = PyNumber_Or(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __Pyx_INCREF(__pyx_v_msg);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_msg);
    __Pyx_GIVEREF(__pyx_v_msg);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_10));
    if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__copy), __pyx_v_copy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__track), __pyx_v_track) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = PyEval_CallObjectWithKeywords(__pyx_t_2, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "zmq/core/socket.pyx":692
 *             self.send(msg, SNDMORE|flags, copy=copy, track=track)
 *         # Send the last part without the extra SNDMORE flag.
 *         return self.send(msg_parts[-1], flags, copy=copy, track=track)             # <<<<<<<<<<<<<<
 * 
 *     def recv_multipart(self, int flags=0, copy=True, track=False):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__send); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_msg_parts, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_10 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_10);
  __pyx_t_6 = 0;
  __pyx_t_10 = 0;
  __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_10));
  if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__copy), __pyx_v_copy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__track), __pyx_v_track) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = PyEval_CallObjectWithKeywords(__pyx_t_7, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("zmq.core.socket.Socket.send_multipart", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XDECREF(__pyx_v_prefix);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":694
 *         return self.send(msg_parts[-1], flags, copy=copy, track=track)
 * 
 *     def recv_multipart(self, int flags=0, copy=True, track=False):             # <<<<<<<<<<<<<<
 *         """s.recv_multipart(flags=0, copy=True, track=False)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_18recv_multipart(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_18recv_multipart[] = "s.recv_multipart(flags=0, copy=True, track=False)\n\n        Receive a multipart message as a list of messages.\n\n        Parameters\n        ----------\n        flags : int, optional\n            Any supported flag: NOBLOCK. If NOBLOCK is set, this method\n            will raise a ZMQError with EAGAIN if a message is not ready.\n            If NOBLOCK is not set, then this method will block until a\n            message arrives.\n        copy : bool, optional\n            Should the message(s) be received in a copying or non-copying manner?\n            If False a Message object is returned for part, if True a string copy of\n            message is returned for each message part.\n        track : bool, optional\n            Should the message(s) be tracked for notification that ZMQ has\n            finished with it? (ignored if copy=True)\n        Returns\n        -------\n        msg_parts : list\n            A list of messages in the multipart message; either Messages or bytes,\n            depending on `copy`.\n        \n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_18recv_multipart(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_flags;
  PyObject *__pyx_v_copy = 0;
  PyObject *__pyx_v_track = 0;
  PyObject *__pyx_v_parts = NULL;
  PyObject *__pyx_v_part = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__flags,&__pyx_n_s__copy,&__pyx_n_s__track,0};
  __Pyx_RefNannySetupContext("recv_multipart");
  {
    PyObject* values[3] = {0,0,0};
    values[1] = __pyx_k_28;
    values[2] = __pyx_k_29;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__copy);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "recv_multipart") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_flags = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_flags = ((int)0);
    }
    __pyx_v_copy = values[1];
    __pyx_v_track = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("recv_multipart", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.recv_multipart", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "zmq/core/socket.pyx":720
 * 
 *         """
 *         parts = [self.recv(flags, copy=copy, track=track)]             # <<<<<<<<<<<<<<
 *         # have first part already, only loop while more to receive
 *         while self.getsockopt(ZMQ_RCVMORE):
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__recv); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__copy), __pyx_v_copy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__track), __pyx_v_track) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_v_parts = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "zmq/core/socket.pyx":722
 *         parts = [self.recv(flags, copy=copy, track=track)]
 *         # have first part already, only loop while more to receive
 *         while self.getsockopt(ZMQ_RCVMORE):             # <<<<<<<<<<<<<<
 *             part = self.recv(flags, copy=copy, track=track)
 *             parts.append(part)
 */
  while (1) {
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__getsockopt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyInt_FromLong(ZMQ_RCVMORE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!__pyx_t_5) break;

    /* "zmq/core/socket.pyx":723
 *         # have first part already, only loop while more to receive
 *         while self.getsockopt(ZMQ_RCVMORE):
 *             part = self.recv(flags, copy=copy, track=track)             # <<<<<<<<<<<<<<
 *             parts.append(part)
 * 
 */
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__recv); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__copy), __pyx_v_copy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__track), __pyx_v_track) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_t_4, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __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_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_v_part);
    __pyx_v_part = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "zmq/core/socket.pyx":724
 *         while self.getsockopt(ZMQ_RCVMORE):
 *             part = self.recv(flags, copy=copy, track=track)
 *             parts.append(part)             # <<<<<<<<<<<<<<
 * 
 *         return parts
 */
    if (unlikely(((PyObject *)__pyx_v_parts) == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_6 = PyList_Append(__pyx_v_parts, __pyx_v_part); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "zmq/core/socket.pyx":726
 *             parts.append(part)
 * 
 *         return parts             # <<<<<<<<<<<<<<
 * 
 *     def send_unicode(self, u, int flags=0, copy=False, encoding='utf-8'):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_parts));
  __pyx_r = ((PyObject *)__pyx_v_parts);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("zmq.core.socket.Socket.recv_multipart", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_parts);
  __Pyx_XDECREF(__pyx_v_part);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":728
 *         return parts
 * 
 *     def send_unicode(self, u, int flags=0, copy=False, encoding='utf-8'):             # <<<<<<<<<<<<<<
 *         """s.send_unicode(u, flags=0, copy=False, encoding='utf-8')
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_19send_unicode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_19send_unicode[] = "s.send_unicode(u, flags=0, copy=False, encoding='utf-8')\n\n        Send a Python unicode object as a message with an encoding.\n\n        Parameters\n        ----------\n        u : Python unicode object\n            The unicode string to send.\n        flags : int, optional\n            Any valid send flag.\n        encoding : str [default: 'utf-8']\n            The encoding to be used\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_19send_unicode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_u = 0;
  int __pyx_v_flags;
  PyObject *__pyx_v_copy = 0;
  PyObject *__pyx_v_encoding = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__u,&__pyx_n_s__flags,&__pyx_n_s__copy,&__pyx_n_s__encoding,0};
  __Pyx_RefNannySetupContext("send_unicode");
  {
    PyObject* values[4] = {0,0,0,0};
    values[2] = __pyx_k_30;
    values[3] = ((PyObject *)__pyx_kp_s_6);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__u);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__copy);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__encoding);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "send_unicode") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_u = values[0];
    if (values[1]) {
      __pyx_v_flags = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_flags = ((int)0);
    }
    __pyx_v_copy = values[2];
    __pyx_v_encoding = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("send_unicode", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.send_unicode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "zmq/core/socket.pyx":742
 *             The encoding to be used
 *         """
 *         if not isinstance(u, basestring):             # <<<<<<<<<<<<<<
 *             raise TypeError("unicode/str objects only")
 *         return self.send(u.encode(encoding), flags=flags, copy=copy)
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__basestring); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_IsInstance(__pyx_v_u, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (!__pyx_t_2);
  if (__pyx_t_3) {

    /* "zmq/core/socket.pyx":743
 *         """
 *         if not isinstance(u, basestring):
 *             raise TypeError("unicode/str objects only")             # <<<<<<<<<<<<<<
 *         return self.send(u.encode(encoding), flags=flags, copy=copy)
 * 
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_32), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "zmq/core/socket.pyx":744
 *         if not isinstance(u, basestring):
 *             raise TypeError("unicode/str objects only")
 *         return self.send(u.encode(encoding), flags=flags, copy=copy)             # <<<<<<<<<<<<<<
 * 
 *     def recv_unicode(self, int flags=0, encoding='utf-8'):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__send); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_u, __pyx_n_s__encode); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __Pyx_INCREF(__pyx_v_encoding);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_encoding);
  __Pyx_GIVEREF(__pyx_v_encoding);
  __pyx_t_6 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  __pyx_t_4 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__flags), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__copy), __pyx_v_copy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("zmq.core.socket.Socket.send_unicode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":746
 *         return self.send(u.encode(encoding), flags=flags, copy=copy)
 * 
 *     def recv_unicode(self, int flags=0, encoding='utf-8'):             # <<<<<<<<<<<<<<
 *         """s.recv_unicode(flags=0, encoding='utf-8')
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_20recv_unicode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_20recv_unicode[] = "s.recv_unicode(flags=0, encoding='utf-8')\n\n        Receive a unicode string, as sent by send_unicode.\n        \n        Parameters\n        ----------\n        flags : int\n            Any valid recv flag.\n        encoding : str [default: 'utf-8']\n            The encoding to be used\n\n        Returns\n        -------\n        s : unicode string\n            The Python unicode string that arrives as message bytes.\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_20recv_unicode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_flags;
  PyObject *__pyx_v_encoding = 0;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__flags,&__pyx_n_s__encoding,0};
  __Pyx_RefNannySetupContext("recv_unicode");
  {
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_kp_s_6);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__encoding);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "recv_unicode") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_flags = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_flags = ((int)0);
    }
    __pyx_v_encoding = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("recv_unicode", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.recv_unicode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "zmq/core/socket.pyx":763
 *             The Python unicode string that arrives as message bytes.
 *         """
 *         msg = self.recv(flags=flags, copy=False)             # <<<<<<<<<<<<<<
 *         return codecs.decode(msg.bytes, encoding)
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__recv); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__flags), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__copy), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_msg = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "zmq/core/socket.pyx":764
 *         """
 *         msg = self.recv(flags=flags, copy=False)
 *         return codecs.decode(msg.bytes, encoding)             # <<<<<<<<<<<<<<
 * 
 *     def send_pyobj(self, obj, flags=0, protocol=-1):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__codecs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__decode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_msg, __pyx_n_s__bytes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_encoding);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_encoding);
  __Pyx_GIVEREF(__pyx_v_encoding);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("zmq.core.socket.Socket.recv_unicode", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":766
 *         return codecs.decode(msg.bytes, encoding)
 * 
 *     def send_pyobj(self, obj, flags=0, protocol=-1):             # <<<<<<<<<<<<<<
 *         """s.send_pyobj(obj, flags=0, protocol=-1)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_21send_pyobj(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_21send_pyobj[] = "s.send_pyobj(obj, flags=0, protocol=-1)\n\n        Send a Python object as a message using pickle to serialize.\n\n        Parameters\n        ----------\n        obj : Python object\n            The Python object to send.\n        flags : int\n            Any valid send flag.\n        protocol : int\n            The pickle protocol number to use. Default of -1 will select\n            the highest supported number. Use 0 for multiple platform\n            support.\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_21send_pyobj(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_obj = 0;
  PyObject *__pyx_v_flags = 0;
  PyObject *__pyx_v_protocol = 0;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__obj,&__pyx_n_s__flags,&__pyx_n_s__protocol,0};
  __Pyx_RefNannySetupContext("send_pyobj");
  {
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)__pyx_int_0);
    values[2] = ((PyObject *)__pyx_int_neg_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__obj);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__protocol);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "send_pyobj") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_obj = values[0];
    __pyx_v_flags = values[1];
    __pyx_v_protocol = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("send_pyobj", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.send_pyobj", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "zmq/core/socket.pyx":782
 *             support.
 *         """
 *         msg = pickle.dumps(obj, protocol)             # <<<<<<<<<<<<<<
 *         return self.send(msg, flags)
 * 
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__pickle); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__dumps); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_v_obj);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_obj);
  __Pyx_GIVEREF(__pyx_v_obj);
  __Pyx_INCREF(__pyx_v_protocol);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_protocol);
  __Pyx_GIVEREF(__pyx_v_protocol);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_msg = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "zmq/core/socket.pyx":783
 *         """
 *         msg = pickle.dumps(obj, protocol)
 *         return self.send(msg, flags)             # <<<<<<<<<<<<<<
 * 
 *     def recv_pyobj(self, flags=0):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_v_flags); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5.__pyx_n = 1;
  __pyx_t_5.flags = __pyx_t_4;
  __pyx_t_3 = ((struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->__pyx_vtab)->send(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), __pyx_v_msg, 0, &__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("zmq.core.socket.Socket.send_pyobj", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":785
 *         return self.send(msg, flags)
 * 
 *     def recv_pyobj(self, flags=0):             # <<<<<<<<<<<<<<
 *         """s.recv_pyobj(flags=0)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_22recv_pyobj(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_22recv_pyobj[] = "s.recv_pyobj(flags=0)\n\n        Receive a Python object as a message using pickle to serialize.\n\n        Parameters\n        ----------\n        flags : int\n            Any valid recv flag.\n\n        Returns\n        -------\n        obj : Python object\n            The Python object that arrives as a message.\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_22recv_pyobj(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_flags = 0;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__flags,0};
  __Pyx_RefNannySetupContext("recv_pyobj");
  {
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "recv_pyobj") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_flags = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("recv_pyobj", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.recv_pyobj", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "zmq/core/socket.pyx":800
 *             The Python object that arrives as a message.
 *         """
 *         s = self.recv(flags)             # <<<<<<<<<<<<<<
 *         return pickle.loads(s)
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_flags); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3.__pyx_n = 1;
  __pyx_t_3.flags = __pyx_t_1;
  __pyx_t_2 = ((struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->__pyx_vtab)->recv(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), 0, &__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_s = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "zmq/core/socket.pyx":801
 *         """
 *         s = self.recv(flags)
 *         return pickle.loads(s)             # <<<<<<<<<<<<<<
 * 
 *     def send_json(self, obj, flags=0):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pickle); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__loads); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_s);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_s);
  __Pyx_GIVEREF(__pyx_v_s);
  __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("zmq.core.socket.Socket.recv_pyobj", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":803
 *         return pickle.loads(s)
 * 
 *     def send_json(self, obj, flags=0):             # <<<<<<<<<<<<<<
 *         """s.send_json(obj, flags=0)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_23send_json(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_23send_json[] = "s.send_json(obj, flags=0)\n\n        Send a Python object as a message using json to serialize.\n\n        Parameters\n        ----------\n        obj : Python object\n            The Python object to send.\n        flags : int\n            Any valid send flag.\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_23send_json(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_obj = 0;
  PyObject *__pyx_v_flags = 0;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__obj,&__pyx_n_s__flags,0};
  __Pyx_RefNannySetupContext("send_json");
  {
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__obj);
        if (likely(values[0])) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "send_json") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_obj = values[0];
    __pyx_v_flags = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("send_json", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.send_json", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "zmq/core/socket.pyx":815
 *             Any valid send flag.
 *         """
 *         if jsonapi.jsonmod is None:             # <<<<<<<<<<<<<<
 *             raise ImportError('jsonlib{1,2}, json or simplejson library is required.')
 *         else:
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__jsonapi); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__jsonmod); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 == Py_None);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "zmq/core/socket.pyx":816
 *         """
 *         if jsonapi.jsonmod is None:
 *             raise ImportError('jsonlib{1,2}, json or simplejson library is required.')             # <<<<<<<<<<<<<<
 *         else:
 *             msg = jsonapi.dumps(obj)
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ImportError, ((PyObject *)__pyx_k_tuple_34), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  /*else*/ {

    /* "zmq/core/socket.pyx":818
 *             raise ImportError('jsonlib{1,2}, json or simplejson library is required.')
 *         else:
 *             msg = jsonapi.dumps(obj)             # <<<<<<<<<<<<<<
 *             return self.send(msg, flags)
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__jsonapi); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__dumps); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(__pyx_v_obj);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_obj);
    __Pyx_GIVEREF(__pyx_v_obj);
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_v_msg = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "zmq/core/socket.pyx":819
 *         else:
 *             msg = jsonapi.dumps(obj)
 *             return self.send(msg, flags)             # <<<<<<<<<<<<<<
 * 
 *     def recv_json(self, flags=0):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_v_flags); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6.__pyx_n = 1;
    __pyx_t_6.flags = __pyx_t_5;
    __pyx_t_4 = ((struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->__pyx_vtab)->send(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), __pyx_v_msg, 0, &__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
  }
  __pyx_L6:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("zmq.core.socket.Socket.send_json", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":821
 *             return self.send(msg, flags)
 * 
 *     def recv_json(self, flags=0):             # <<<<<<<<<<<<<<
 *         """s.recv_json(flags=0)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_24recv_json(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_24recv_json[] = "s.recv_json(flags=0)\n\n        Receive a Python object as a message using json to serialize.\n\n        Parameters\n        ----------\n        flags : int\n            Any valid recv flag.\n\n        Returns\n        -------\n        obj : Python object\n            The Python object that arrives as a message.\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_24recv_json(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_flags = 0;
  PyObject *__pyx_v_msg = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__flags,0};
  __Pyx_RefNannySetupContext("recv_json");
  {
    PyObject* values[1] = {0};
    values[0] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "recv_json") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_flags = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("recv_json", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.recv_json", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "zmq/core/socket.pyx":836
 *             The Python object that arrives as a message.
 *         """
 *         if jsonapi.jsonmod is None:             # <<<<<<<<<<<<<<
 *             raise ImportError('jsonlib{1,2}, json or simplejson library is required.')
 *         else:
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__jsonapi); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__jsonmod); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 == Py_None);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "zmq/core/socket.pyx":837
 *         """
 *         if jsonapi.jsonmod is None:
 *             raise ImportError('jsonlib{1,2}, json or simplejson library is required.')             # <<<<<<<<<<<<<<
 *         else:
 *             msg = self.recv(flags)
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ImportError, ((PyObject *)__pyx_k_tuple_35), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  /*else*/ {

    /* "zmq/core/socket.pyx":839
 *             raise ImportError('jsonlib{1,2}, json or simplejson library is required.')
 *         else:
 *             msg = self.recv(flags)             # <<<<<<<<<<<<<<
 *             return jsonapi.loads(msg)
 * 
 */
    __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_v_flags); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5.__pyx_n = 1;
    __pyx_t_5.flags = __pyx_t_4;
    __pyx_t_2 = ((struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->__pyx_vtab)->recv(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), 0, &__pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_msg = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "zmq/core/socket.pyx":840
 *         else:
 *             msg = self.recv(flags)
 *             return jsonapi.loads(msg)             # <<<<<<<<<<<<<<
 * 
 *     def poll(self, timeout=None, flags=None):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__jsonapi); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__loads); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(__pyx_v_msg);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_msg);
    __Pyx_GIVEREF(__pyx_v_msg);
    __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L0;
  }
  __pyx_L6:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("zmq.core.socket.Socket.recv_json", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_msg);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pyx":842
 *             return jsonapi.loads(msg)
 * 
 *     def poll(self, timeout=None, flags=None):             # <<<<<<<<<<<<<<
 *         """s.poll(timeout=None, flags=POLLIN|POLLERR)
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_25poll(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_3zmq_4core_6socket_6Socket_25poll[] = "s.poll(timeout=None, flags=POLLIN|POLLERR)\n        \n        Poll the socket for events.  The default is to poll forever for incoming\n        events.  Timeout is in milliseconds, if specified.\n        \n        Parameters\n        ----------\n        timeout : int [default: None]\n            The timeout (in milliseconds) to wait for an event. If unspecified\n            (or secified None), will wait forever for an event.\n        flags : bitfield (int) [default: any event]\n            The event flags to poll for (any combination of POLLIN|POLLOUT|POLLERR).\n            The default is to check for incoming events (POLLIN|POLLERR).\n        \n        Returns\n        -------\n        events : bitfield (int)\n            The events that are ready and waiting.  Will be 0 if no events were ready\n            by the time timeout was reached.\n        ";
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_25poll(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_timeout = 0;
  PyObject *__pyx_v_flags = 0;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_v_evts = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__timeout,&__pyx_n_s__flags,0};
  __Pyx_RefNannySetupContext("poll");
  {
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__timeout);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "poll") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_timeout = values[0];
    __pyx_v_flags = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("poll", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.poll", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF(__pyx_v_flags);

  /* "zmq/core/socket.pyx":864
 *         """
 * 
 *         _check_closed(self, True)             # <<<<<<<<<<<<<<
 * 
 *         if flags is None:
 */
  __pyx_t_1 = __pyx_f_3zmq_4core_6socket__check_closed(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "zmq/core/socket.pyx":866
 *         _check_closed(self, True)
 * 
 *         if flags is None:             # <<<<<<<<<<<<<<
 *             flags = POLLIN|POLLERR
 *         p = zmq.Poller()
 */
  __pyx_t_2 = (__pyx_v_flags == Py_None);
  if (__pyx_t_2) {

    /* "zmq/core/socket.pyx":867
 * 
 *         if flags is None:
 *             flags = POLLIN|POLLERR             # <<<<<<<<<<<<<<
 *         p = zmq.Poller()
 *         p.register(self, flags)
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__POLLIN); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__POLLERR); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Or(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_v_flags);
    __pyx_v_flags = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "zmq/core/socket.pyx":868
 *         if flags is None:
 *             flags = POLLIN|POLLERR
 *         p = zmq.Poller()             # <<<<<<<<<<<<<<
 *         p.register(self, flags)
 *         evts = dict(p.poll(timeout))
 */
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__zmq); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__Poller); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_p = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "zmq/core/socket.pyx":869
 *             flags = POLLIN|POLLERR
 *         p = zmq.Poller()
 *         p.register(self, flags)             # <<<<<<<<<<<<<<
 *         evts = dict(p.poll(timeout))
 *         # return 0 if no events, otherwise return event bitfield
 */
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_p, __pyx_n_s__register); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __Pyx_INCREF(__pyx_v_flags);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_flags);
  __Pyx_GIVEREF(__pyx_v_flags);
  __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 = 869; __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;

  /* "zmq/core/socket.pyx":870
 *         p = zmq.Poller()
 *         p.register(self, flags)
 *         evts = dict(p.poll(timeout))             # <<<<<<<<<<<<<<
 *         # return 0 if no events, otherwise return event bitfield
 *         return evts.get(self, 0)
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_p, __pyx_n_s__poll); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_v_timeout);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_timeout);
  __Pyx_GIVEREF(__pyx_v_timeout);
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyDict_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_evts = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "zmq/core/socket.pyx":872
 *         evts = dict(p.poll(timeout))
 *         # return 0 if no events, otherwise return event bitfield
 *         return evts.get(self, 0)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(((PyObject *)__pyx_v_evts) == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_4 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_evts), __pyx_v_self, __pyx_int_0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("zmq.core.socket.Socket.poll", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_evts);
  __Pyx_XDECREF(__pyx_v_flags);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pxd":39
 * 
 *     cdef void *handle           # The C handle for the underlying zmq object.
 *     cdef public int socket_type # The 0MQ socket type - REQ,REP, etc.             # <<<<<<<<<<<<<<
 *     # Hold on to a reference to the context to make sure it is not garbage
 *     # collected until the socket it done with it.
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_11socket_type___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_11socket_type___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->socket_type); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("zmq.core.socket.Socket.socket_type.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_3zmq_4core_6socket_6Socket_11socket_type_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_3zmq_4core_6socket_6Socket_11socket_type_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__");
  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->socket_type = __pyx_t_1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.socket_type.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pxd":42
 *     # Hold on to a reference to the context to make sure it is not garbage
 *     # collected until the socket it done with it.
 *     cdef public Context context # The zmq Context object that owns this.             # <<<<<<<<<<<<<<
 *     cdef public bint _closed   # bool property for a closed socket.
 *     cdef dict _attrs   # dict needed for *non-sockopt* get/setattr in subclasses
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_7context___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_7context___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context));
  __pyx_r = ((PyObject *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_3zmq_4core_6socket_6Socket_7context_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_3zmq_4core_6socket_6Socket_7context_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__");
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_3zmq_4core_7context_Context))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context));
  ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context = ((struct __pyx_obj_3zmq_4core_7context_Context *)__pyx_v_value);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket.context.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_3zmq_4core_6socket_6Socket_7context_2__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pf_3zmq_4core_6socket_6Socket_7context_2__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__");
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context));
  ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context = ((struct __pyx_obj_3zmq_4core_7context_Context *)Py_None);

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "zmq/core/socket.pxd":43
 *     # collected until the socket it done with it.
 *     cdef public Context context # The zmq Context object that owns this.
 *     cdef public bint _closed   # bool property for a closed socket.             # <<<<<<<<<<<<<<
 *     cdef dict _attrs   # dict needed for *non-sockopt* get/setattr in subclasses
 * 
 */

static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_7_closed___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_7_closed___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->_closed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("zmq.core.socket.Socket._closed.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_3zmq_4core_6socket_6Socket_7_closed_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pf_3zmq_4core_6socket_6Socket_7_closed_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__");
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->_closed = __pyx_t_1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("zmq.core.socket.Socket._closed.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "buffers.pxd":79
 * 
 * 
 * cdef inline int newstyle_available():             # <<<<<<<<<<<<<<
 *     return PY_MAJOR_VERSION >= 3 or (PY_MAJOR_VERSION >=2 and PY_MINOR_VERSION >= 6)
 * 
 */

static CYTHON_INLINE int __pyx_f_7buffers_newstyle_available(void) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("newstyle_available");

  /* "buffers.pxd":80
 * 
 * cdef inline int newstyle_available():
 *     return PY_MAJOR_VERSION >= 3 or (PY_MAJOR_VERSION >=2 and PY_MINOR_VERSION >= 6)             # <<<<<<<<<<<<<<
 * 
 * cdef inline int memoryview_available():
 */
  __pyx_t_1 = (PY_MAJOR_VERSION >= 3);
  if (!__pyx_t_1) {
    __pyx_t_2 = (PY_MAJOR_VERSION >= 2);
    if (__pyx_t_2) {
      __pyx_t_3 = (PY_MINOR_VERSION >= 6);
      __pyx_t_4 = __pyx_t_3;
    } else {
      __pyx_t_4 = __pyx_t_2;
    }
    __pyx_t_2 = __pyx_t_4;
  } else {
    __pyx_t_2 = __pyx_t_1;
  }
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "buffers.pxd":82
 *     return PY_MAJOR_VERSION >= 3 or (PY_MAJOR_VERSION >=2 and PY_MINOR_VERSION >= 6)
 * 
 * cdef inline int memoryview_available():             # <<<<<<<<<<<<<<
 *     return PY_MAJOR_VERSION >= 3 or (PY_MAJOR_VERSION >=2 and PY_MINOR_VERSION >= 7)
 * 
 */

static CYTHON_INLINE int __pyx_f_7buffers_memoryview_available(void) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("memoryview_available");

  /* "buffers.pxd":83
 * 
 * cdef inline int memoryview_available():
 *     return PY_MAJOR_VERSION >= 3 or (PY_MAJOR_VERSION >=2 and PY_MINOR_VERSION >= 7)             # <<<<<<<<<<<<<<
 * 
 * cdef inline int oldstyle_available():
 */
  __pyx_t_1 = (PY_MAJOR_VERSION >= 3);
  if (!__pyx_t_1) {
    __pyx_t_2 = (PY_MAJOR_VERSION >= 2);
    if (__pyx_t_2) {
      __pyx_t_3 = (PY_MINOR_VERSION >= 7);
      __pyx_t_4 = __pyx_t_3;
    } else {
      __pyx_t_4 = __pyx_t_2;
    }
    __pyx_t_2 = __pyx_t_4;
  } else {
    __pyx_t_2 = __pyx_t_1;
  }
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "buffers.pxd":85
 *     return PY_MAJOR_VERSION >= 3 or (PY_MAJOR_VERSION >=2 and PY_MINOR_VERSION >= 7)
 * 
 * cdef inline int oldstyle_available():             # <<<<<<<<<<<<<<
 *     return PY_MAJOR_VERSION < 3
 * 
 */

static CYTHON_INLINE int __pyx_f_7buffers_oldstyle_available(void) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("oldstyle_available");

  /* "buffers.pxd":86
 * 
 * cdef inline int oldstyle_available():
 *     return PY_MAJOR_VERSION < 3             # <<<<<<<<<<<<<<
 * 
 * cdef inline int check_buffer(object ob):
 */
  __pyx_r = (PY_MAJOR_VERSION < 3);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "buffers.pxd":88
 *     return PY_MAJOR_VERSION < 3
 * 
 * cdef inline int check_buffer(object ob):             # <<<<<<<<<<<<<<
 *     """Version independent check for whether an object is a buffer.
 * 
 */

static CYTHON_INLINE int __pyx_f_7buffers_check_buffer(PyObject *__pyx_v_ob) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  long __pyx_t_2;
  __Pyx_RefNannySetupContext("check_buffer");

  /* "buffers.pxd":100
 *     int : 0 if no buffer interface, 3 if newstyle buffer interface, 2 if oldstyle.
 *     """
 *     if newstyle_available():             # <<<<<<<<<<<<<<
 *         if PyObject_CheckBuffer(ob):
 *             return 3
 */
  __pyx_t_1 = __pyx_f_7buffers_newstyle_available();
  if (__pyx_t_1) {

    /* "buffers.pxd":101
 *     """
 *     if newstyle_available():
 *         if PyObject_CheckBuffer(ob):             # <<<<<<<<<<<<<<
 *             return 3
 *     if oldstyle_available():
 */
    __pyx_t_1 = PyObject_CheckBuffer(__pyx_v_ob);
    if (__pyx_t_1) {

      /* "buffers.pxd":102
 *     if newstyle_available():
 *         if PyObject_CheckBuffer(ob):
 *             return 3             # <<<<<<<<<<<<<<
 *     if oldstyle_available():
 *         return PyObject_CheckReadBuffer(ob) and 2
 */
      __pyx_r = 3;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "buffers.pxd":103
 *         if PyObject_CheckBuffer(ob):
 *             return 3
 *     if oldstyle_available():             # <<<<<<<<<<<<<<
 *         return PyObject_CheckReadBuffer(ob) and 2
 *     return 0
 */
  __pyx_t_1 = __pyx_f_7buffers_oldstyle_available();
  if (__pyx_t_1) {

    /* "buffers.pxd":104
 *             return 3
 *     if oldstyle_available():
 *         return PyObject_CheckReadBuffer(ob) and 2             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
    __pyx_t_1 = PyObject_CheckReadBuffer(__pyx_v_ob);
    if (__pyx_t_1) {
      __pyx_t_2 = 2;
    } else {
      __pyx_t_2 = __pyx_t_1;
    }
    __pyx_r = __pyx_t_2;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "buffers.pxd":105
 *     if oldstyle_available():
 *         return PyObject_CheckReadBuffer(ob) and 2
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "buffers.pxd":108
 * 
 * 
 * cdef inline object asbuffer(object ob, int writable, int format,             # <<<<<<<<<<<<<<
 *                             void **base, Py_ssize_t *size,
 *                             Py_ssize_t *itemsize):
 */

static CYTHON_INLINE PyObject *__pyx_f_7buffers_asbuffer(PyObject *__pyx_v_ob, int __pyx_v_writable, int __pyx_v_format, void **__pyx_v_base, Py_ssize_t *__pyx_v_size, Py_ssize_t *__pyx_v_itemsize) {
  void *__pyx_v_bptr;
  Py_ssize_t __pyx_v_blen;
  Py_ssize_t __pyx_v_bitemlen;
  PyObject *__pyx_v_bfmt = 0;
  Py_buffer __pyx_v_view;
  int __pyx_v_flags;
  int __pyx_v_mode;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("asbuffer");

  /* "buffers.pxd":135
 *     """
 * 
 *     cdef void *bptr = NULL             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t blen = 0, bitemlen = 0
 *     cdef str bfmt = None
 */
  __pyx_v_bptr = NULL;

  /* "buffers.pxd":136
 * 
 *     cdef void *bptr = NULL
 *     cdef Py_ssize_t blen = 0, bitemlen = 0             # <<<<<<<<<<<<<<
 *     cdef str bfmt = None
 *     cdef Py_buffer view
 */
  __pyx_v_blen = 0;
  __pyx_v_bitemlen = 0;

  /* "buffers.pxd":137
 *     cdef void *bptr = NULL
 *     cdef Py_ssize_t blen = 0, bitemlen = 0
 *     cdef str bfmt = None             # <<<<<<<<<<<<<<
 *     cdef Py_buffer view
 *     cdef int flags = PyBUF_SIMPLE
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_bfmt = ((PyObject*)Py_None);

  /* "buffers.pxd":139
 *     cdef str bfmt = None
 *     cdef Py_buffer view
 *     cdef int flags = PyBUF_SIMPLE             # <<<<<<<<<<<<<<
 *     cdef int mode = 0
 * 
 */
  __pyx_v_flags = PyBUF_SIMPLE;

  /* "buffers.pxd":140
 *     cdef Py_buffer view
 *     cdef int flags = PyBUF_SIMPLE
 *     cdef int mode = 0             # <<<<<<<<<<<<<<
 * 
 *     mode = check_buffer(ob)
 */
  __pyx_v_mode = 0;

  /* "buffers.pxd":142
 *     cdef int mode = 0
 * 
 *     mode = check_buffer(ob)             # <<<<<<<<<<<<<<
 *     if mode == 0:
 *         raise TypeError("%r does not provide a buffer interface."%ob)
 */
  __pyx_v_mode = __pyx_f_7buffers_check_buffer(__pyx_v_ob);

  /* "buffers.pxd":143
 * 
 *     mode = check_buffer(ob)
 *     if mode == 0:             # <<<<<<<<<<<<<<
 *         raise TypeError("%r does not provide a buffer interface."%ob)
 * 
 */
  __pyx_t_1 = (__pyx_v_mode == 0);
  if (__pyx_t_1) {

    /* "buffers.pxd":144
 *     mode = check_buffer(ob)
 *     if mode == 0:
 *         raise TypeError("%r does not provide a buffer interface."%ob)             # <<<<<<<<<<<<<<
 * 
 *     if mode == 3:
 */
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_36), __pyx_v_ob); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "buffers.pxd":146
 *         raise TypeError("%r does not provide a buffer interface."%ob)
 * 
 *     if mode == 3:             # <<<<<<<<<<<<<<
 *         flags = PyBUF_ANY_CONTIGUOUS
 *         if writable:
 */
  __pyx_t_1 = (__pyx_v_mode == 3);
  if (__pyx_t_1) {

    /* "buffers.pxd":147
 * 
 *     if mode == 3:
 *         flags = PyBUF_ANY_CONTIGUOUS             # <<<<<<<<<<<<<<
 *         if writable:
 *             flags |= PyBUF_WRITABLE
 */
    __pyx_v_flags = PyBUF_ANY_CONTIGUOUS;

    /* "buffers.pxd":148
 *     if mode == 3:
 *         flags = PyBUF_ANY_CONTIGUOUS
 *         if writable:             # <<<<<<<<<<<<<<
 *             flags |= PyBUF_WRITABLE
 *         if format:
 */
    if (__pyx_v_writable) {

      /* "buffers.pxd":149
 *         flags = PyBUF_ANY_CONTIGUOUS
 *         if writable:
 *             flags |= PyBUF_WRITABLE             # <<<<<<<<<<<<<<
 *         if format:
 *             flags |= PyBUF_FORMAT
 */
      __pyx_v_flags = (__pyx_v_flags | PyBUF_WRITABLE);
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "buffers.pxd":150
 *         if writable:
 *             flags |= PyBUF_WRITABLE
 *         if format:             # <<<<<<<<<<<<<<
 *             flags |= PyBUF_FORMAT
 *         PyObject_GetBuffer(ob, &view, flags)
 */
    if (__pyx_v_format) {

      /* "buffers.pxd":151
 *             flags |= PyBUF_WRITABLE
 *         if format:
 *             flags |= PyBUF_FORMAT             # <<<<<<<<<<<<<<
 *         PyObject_GetBuffer(ob, &view, flags)
 *         bptr = view.buf
 */
      __pyx_v_flags = (__pyx_v_flags | PyBUF_FORMAT);
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "buffers.pxd":152
 *         if format:
 *             flags |= PyBUF_FORMAT
 *         PyObject_GetBuffer(ob, &view, flags)             # <<<<<<<<<<<<<<
 *         bptr = view.buf
 *         blen = view.len
 */
    __pyx_t_4 = PyObject_GetBuffer(__pyx_v_ob, (&__pyx_v_view), __pyx_v_flags); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "buffers.pxd":153
 *             flags |= PyBUF_FORMAT
 *         PyObject_GetBuffer(ob, &view, flags)
 *         bptr = view.buf             # <<<<<<<<<<<<<<
 *         blen = view.len
 *         if format:
 */
    __pyx_v_bptr = __pyx_v_view.buf;

    /* "buffers.pxd":154
 *         PyObject_GetBuffer(ob, &view, flags)
 *         bptr = view.buf
 *         blen = view.len             # <<<<<<<<<<<<<<
 *         if format:
 *             if view.format != NULL:
 */
    __pyx_v_blen = __pyx_v_view.len;

    /* "buffers.pxd":155
 *         bptr = view.buf
 *         blen = view.len
 *         if format:             # <<<<<<<<<<<<<<
 *             if view.format != NULL:
 *                 bfmt = view.format
 */
    if (__pyx_v_format) {

      /* "buffers.pxd":156
 *         blen = view.len
 *         if format:
 *             if view.format != NULL:             # <<<<<<<<<<<<<<
 *                 bfmt = view.format
 *                 bitemlen = view.itemsize
 */
      __pyx_t_1 = (__pyx_v_view.format != NULL);
      if (__pyx_t_1) {

        /* "buffers.pxd":157
 *         if format:
 *             if view.format != NULL:
 *                 bfmt = view.format             # <<<<<<<<<<<<<<
 *                 bitemlen = view.itemsize
 *         PyBuffer_Release(&view)
 */
        __pyx_t_2 = PyBytes_FromString(__pyx_v_view.format); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
        if (!(likely(PyString_CheckExact(((PyObject *)__pyx_t_2)))||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(((PyObject *)__pyx_t_2))->tp_name), 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(((PyObject *)__pyx_v_bfmt));
        __pyx_v_bfmt = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;

        /* "buffers.pxd":158
 *             if view.format != NULL:
 *                 bfmt = view.format
 *                 bitemlen = view.itemsize             # <<<<<<<<<<<<<<
 *         PyBuffer_Release(&view)
 *     else: # oldstyle
 */
        __pyx_v_bitemlen = __pyx_v_view.itemsize;
        goto __pyx_L8;
      }
      __pyx_L8:;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "buffers.pxd":159
 *                 bfmt = view.format
 *                 bitemlen = view.itemsize
 *         PyBuffer_Release(&view)             # <<<<<<<<<<<<<<
 *     else: # oldstyle
 *         if writable:
 */
    PyBuffer_Release((&__pyx_v_view));
    goto __pyx_L4;
  }
  /*else*/ {

    /* "buffers.pxd":161
 *         PyBuffer_Release(&view)
 *     else: # oldstyle
 *         if writable:             # <<<<<<<<<<<<<<
 *             PyObject_AsWriteBuffer(ob, &bptr, &blen)
 *         else:
 */
    if (__pyx_v_writable) {

      /* "buffers.pxd":162
 *     else: # oldstyle
 *         if writable:
 *             PyObject_AsWriteBuffer(ob, &bptr, &blen)             # <<<<<<<<<<<<<<
 *         else:
 *             PyObject_AsReadBuffer(ob, <const_void **>&bptr, &blen)
 */
      __pyx_t_4 = PyObject_AsWriteBuffer(__pyx_v_ob, (&__pyx_v_bptr), (&__pyx_v_blen)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L9;
    }
    /*else*/ {

      /* "buffers.pxd":164
 *             PyObject_AsWriteBuffer(ob, &bptr, &blen)
 *         else:
 *             PyObject_AsReadBuffer(ob, <const_void **>&bptr, &blen)             # <<<<<<<<<<<<<<
 *         if format:
 *             try: # numpy.ndarray
 */
      __pyx_t_4 = PyObject_AsReadBuffer(__pyx_v_ob, ((const void **)(&__pyx_v_bptr)), (&__pyx_v_blen)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L9:;

    /* "buffers.pxd":165
 *         else:
 *             PyObject_AsReadBuffer(ob, <const_void **>&bptr, &blen)
 *         if format:             # <<<<<<<<<<<<<<
 *             try: # numpy.ndarray
 *                 dtype = ob.dtype
 */
    if (__pyx_v_format) {

      /* "buffers.pxd":166
 *             PyObject_AsReadBuffer(ob, <const_void **>&bptr, &blen)
 *         if format:
 *             try: # numpy.ndarray             # <<<<<<<<<<<<<<
 *                 dtype = ob.dtype
 *                 bfmt = dtype.char
 */
      {
        __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_5);
        __Pyx_XGOTREF(__pyx_t_6);
        __Pyx_XGOTREF(__pyx_t_7);
        /*try:*/ {

          /* "buffers.pxd":167
 *         if format:
 *             try: # numpy.ndarray
 *                 dtype = ob.dtype             # <<<<<<<<<<<<<<
 *                 bfmt = dtype.char
 *                 bitemlen = dtype.itemsize
 */
          __pyx_t_2 = PyObject_GetAttr(__pyx_v_ob, __pyx_n_s__dtype); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_v_dtype = __pyx_t_2;
          __pyx_t_2 = 0;

          /* "buffers.pxd":168
 *             try: # numpy.ndarray
 *                 dtype = ob.dtype
 *                 bfmt = dtype.char             # <<<<<<<<<<<<<<
 *                 bitemlen = dtype.itemsize
 *             except AttributeError:
 */
          __pyx_t_2 = PyObject_GetAttr(__pyx_v_dtype, __pyx_n_s__char); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
          __Pyx_GOTREF(__pyx_t_2);
          if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
          __Pyx_DECREF(((PyObject *)__pyx_v_bfmt));
          __pyx_v_bfmt = ((PyObject*)__pyx_t_2);
          __pyx_t_2 = 0;

          /* "buffers.pxd":169
 *                 dtype = ob.dtype
 *                 bfmt = dtype.char
 *                 bitemlen = dtype.itemsize             # <<<<<<<<<<<<<<
 *             except AttributeError:
 *                 try: # array.array
 */
          __pyx_t_2 = PyObject_GetAttr(__pyx_v_dtype, __pyx_n_s__itemsize); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_v_bitemlen = __pyx_t_8;
        }
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L18_try_end;
        __pyx_L11_error:;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "buffers.pxd":170
 *                 bfmt = dtype.char
 *                 bitemlen = dtype.itemsize
 *             except AttributeError:             # <<<<<<<<<<<<<<
 *                 try: # array.array
 *                     bfmt = ob.typecode
 */
        __pyx_t_4 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
        if (__pyx_t_4) {
          __Pyx_AddTraceback("buffers.asbuffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_9) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GOTREF(__pyx_t_9);

          /* "buffers.pxd":171
 *                 bitemlen = dtype.itemsize
 *             except AttributeError:
 *                 try: # array.array             # <<<<<<<<<<<<<<
 *                     bfmt = ob.typecode
 *                     bitemlen = ob.itemsize
 */
          {
            __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_10);
            __Pyx_XGOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_12);
            /*try:*/ {

              /* "buffers.pxd":172
 *             except AttributeError:
 *                 try: # array.array
 *                     bfmt = ob.typecode             # <<<<<<<<<<<<<<
 *                     bitemlen = ob.itemsize
 *                 except AttributeError:
 */
              __pyx_t_13 = PyObject_GetAttr(__pyx_v_ob, __pyx_n_s__typecode); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L21_error;}
              __Pyx_GOTREF(__pyx_t_13);
              if (!(likely(PyString_CheckExact(__pyx_t_13))||((__pyx_t_13) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_13)->tp_name), 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L21_error;}
              __Pyx_DECREF(((PyObject *)__pyx_v_bfmt));
              __pyx_v_bfmt = ((PyObject*)__pyx_t_13);
              __pyx_t_13 = 0;

              /* "buffers.pxd":173
 *                 try: # array.array
 *                     bfmt = ob.typecode
 *                     bitemlen = ob.itemsize             # <<<<<<<<<<<<<<
 *                 except AttributeError:
 *                     if isinstance(ob, bytes):
 */
              __pyx_t_13 = PyObject_GetAttr(__pyx_v_ob, __pyx_n_s__itemsize); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L21_error;}
              __Pyx_GOTREF(__pyx_t_13);
              __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_13); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L21_error;}
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              __pyx_v_bitemlen = __pyx_t_8;
            }
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            goto __pyx_L28_try_end;
            __pyx_L21_error:;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;

            /* "buffers.pxd":174
 *                     bfmt = ob.typecode
 *                     bitemlen = ob.itemsize
 *                 except AttributeError:             # <<<<<<<<<<<<<<
 *                     if isinstance(ob, bytes):
 *                         bfmt = "B"
 */
            __pyx_t_4 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
            if (__pyx_t_4) {
              __Pyx_AddTraceback("buffers.asbuffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L23_except_error;}
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_GOTREF(__pyx_t_14);
              __Pyx_GOTREF(__pyx_t_15);

              /* "buffers.pxd":175
 *                     bitemlen = ob.itemsize
 *                 except AttributeError:
 *                     if isinstance(ob, bytes):             # <<<<<<<<<<<<<<
 *                         bfmt = "B"
 *                         bitemlen = 1
 */
              __pyx_t_16 = ((PyObject *)((PyObject*)(&PyBytes_Type)));
              __Pyx_INCREF(__pyx_t_16);
              __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_ob, __pyx_t_16); 
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              if (__pyx_t_1) {

                /* "buffers.pxd":176
 *                 except AttributeError:
 *                     if isinstance(ob, bytes):
 *                         bfmt = "B"             # <<<<<<<<<<<<<<
 *                         bitemlen = 1
 *                     else:
 */
                __Pyx_INCREF(((PyObject *)__pyx_n_s__B));
                __Pyx_DECREF(((PyObject *)__pyx_v_bfmt));
                __pyx_v_bfmt = __pyx_n_s__B;

                /* "buffers.pxd":177
 *                     if isinstance(ob, bytes):
 *                         bfmt = "B"
 *                         bitemlen = 1             # <<<<<<<<<<<<<<
 *                     else:
 *                         # nothing found
 */
                __pyx_v_bitemlen = 1;
                goto __pyx_L31;
              }
              /*else*/ {

                /* "buffers.pxd":180
 *                     else:
 *                         # nothing found
 *                         bfmt = None             # <<<<<<<<<<<<<<
 *                         bitemlen = 0
 *     if base: base[0] = <void *>bptr
 */
                __Pyx_INCREF(Py_None);
                __Pyx_DECREF(((PyObject *)__pyx_v_bfmt));
                __pyx_v_bfmt = ((PyObject*)Py_None);

                /* "buffers.pxd":181
 *                         # nothing found
 *                         bfmt = None
 *                         bitemlen = 0             # <<<<<<<<<<<<<<
 *     if base: base[0] = <void *>bptr
 *     if size: size[0] = <Py_ssize_t>blen
 */
                __pyx_v_bitemlen = 0;
              }
              __pyx_L31:;
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              goto __pyx_L22_exception_handled;
            }
            __pyx_L23_except_error:;
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
            goto __pyx_L13_except_error;
            __pyx_L22_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
            __pyx_L28_try_end:;
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          goto __pyx_L12_exception_handled;
        }
        __pyx_L13_except_error:;
        __Pyx_XGIVEREF(__pyx_t_5);
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
        goto __pyx_L1_error;
        __pyx_L12_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_5);
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
        __pyx_L18_try_end:;
      }
      goto __pyx_L10;
    }
    __pyx_L10:;
  }
  __pyx_L4:;

  /* "buffers.pxd":182
 *                         bfmt = None
 *                         bitemlen = 0
 *     if base: base[0] = <void *>bptr             # <<<<<<<<<<<<<<
 *     if size: size[0] = <Py_ssize_t>blen
 *     if itemsize: itemsize[0] = <Py_ssize_t>bitemlen
 */
  __pyx_t_1 = (__pyx_v_base != 0);
  if (__pyx_t_1) {
    (__pyx_v_base[0]) = ((void *)__pyx_v_bptr);
    goto __pyx_L32;
  }
  __pyx_L32:;

  /* "buffers.pxd":183
 *                         bitemlen = 0
 *     if base: base[0] = <void *>bptr
 *     if size: size[0] = <Py_ssize_t>blen             # <<<<<<<<<<<<<<
 *     if itemsize: itemsize[0] = <Py_ssize_t>bitemlen
 *     return bfmt
 */
  __pyx_t_1 = (__pyx_v_size != 0);
  if (__pyx_t_1) {
    (__pyx_v_size[0]) = ((Py_ssize_t)__pyx_v_blen);
    goto __pyx_L33;
  }
  __pyx_L33:;

  /* "buffers.pxd":184
 *     if base: base[0] = <void *>bptr
 *     if size: size[0] = <Py_ssize_t>blen
 *     if itemsize: itemsize[0] = <Py_ssize_t>bitemlen             # <<<<<<<<<<<<<<
 *     return bfmt
 * 
 */
  __pyx_t_1 = (__pyx_v_itemsize != 0);
  if (__pyx_t_1) {
    (__pyx_v_itemsize[0]) = ((Py_ssize_t)__pyx_v_bitemlen);
    goto __pyx_L34;
  }
  __pyx_L34:;

  /* "buffers.pxd":185
 *     if size: size[0] = <Py_ssize_t>blen
 *     if itemsize: itemsize[0] = <Py_ssize_t>bitemlen
 *     return bfmt             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_bfmt));
  __pyx_r = ((PyObject *)__pyx_v_bfmt);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_AddTraceback("buffers.asbuffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_bfmt);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "buffers.pxd":188
 * 
 * 
 * cdef inline object asbuffer_r(object ob, void **base, Py_ssize_t *size):             # <<<<<<<<<<<<<<
 *     """Wrapper for standard calls to asbuffer with a readonly buffer."""
 *     asbuffer(ob, 0, 0, base, size, NULL)
 */

static CYTHON_INLINE PyObject *__pyx_f_7buffers_asbuffer_r(PyObject *__pyx_v_ob, void **__pyx_v_base, Py_ssize_t *__pyx_v_size) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("asbuffer_r");

  /* "buffers.pxd":190
 * cdef inline object asbuffer_r(object ob, void **base, Py_ssize_t *size):
 *     """Wrapper for standard calls to asbuffer with a readonly buffer."""
 *     asbuffer(ob, 0, 0, base, size, NULL)             # <<<<<<<<<<<<<<
 *     return ob
 * 
 */
  __pyx_t_1 = __pyx_f_7buffers_asbuffer(__pyx_v_ob, 0, 0, __pyx_v_base, __pyx_v_size, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "buffers.pxd":191
 *     """Wrapper for standard calls to asbuffer with a readonly buffer."""
 *     asbuffer(ob, 0, 0, base, size, NULL)
 *     return ob             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ob);
  __pyx_r = __pyx_v_ob;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("buffers.asbuffer_r", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "buffers.pxd":194
 * 
 * 
 * cdef inline object asbuffer_w(object ob, void **base, Py_ssize_t *size):             # <<<<<<<<<<<<<<
 *     """Wrapper for standard calls to asbuffer with a writable buffer."""
 *     asbuffer(ob, 1, 0, base, size, NULL)
 */

static CYTHON_INLINE PyObject *__pyx_f_7buffers_asbuffer_w(PyObject *__pyx_v_ob, void **__pyx_v_base, Py_ssize_t *__pyx_v_size) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("asbuffer_w");

  /* "buffers.pxd":196
 * cdef inline object asbuffer_w(object ob, void **base, Py_ssize_t *size):
 *     """Wrapper for standard calls to asbuffer with a writable buffer."""
 *     asbuffer(ob, 1, 0, base, size, NULL)             # <<<<<<<<<<<<<<
 *     return ob
 * 
 */
  __pyx_t_1 = __pyx_f_7buffers_asbuffer(__pyx_v_ob, 1, 0, __pyx_v_base, __pyx_v_size, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "buffers.pxd":197
 *     """Wrapper for standard calls to asbuffer with a writable buffer."""
 *     asbuffer(ob, 1, 0, base, size, NULL)
 *     return ob             # <<<<<<<<<<<<<<
 * 
 * #------------------------------------------------------------------------------
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_ob);
  __pyx_r = __pyx_v_ob;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("buffers.asbuffer_w", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "buffers.pxd":203
 * #------------------------------------------------------------------------------
 * 
 * cdef inline object frombuffer_3(void *ptr, Py_ssize_t s, int readonly):             # <<<<<<<<<<<<<<
 *     """Python 3 version of frombuffer.
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_3(void *__pyx_v_ptr, Py_ssize_t __pyx_v_s, int __pyx_v_readonly) {
  Py_buffer __pyx_v_pybuf;
  Py_ssize_t *__pyx_v_shape;
  PyObject *__pyx_v_astr = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1[1];
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("frombuffer_3");

  /* "buffers.pxd":210
 *     """
 *     cdef Py_buffer pybuf
 *     cdef Py_ssize_t *shape = [s]             # <<<<<<<<<<<<<<
 *     cdef str astr=""
 *     if newstyle_available():
 */
  __pyx_t_1[0] = __pyx_v_s;
  __pyx_v_shape = __pyx_t_1;

  /* "buffers.pxd":211
 *     cdef Py_buffer pybuf
 *     cdef Py_ssize_t *shape = [s]
 *     cdef str astr=""             # <<<<<<<<<<<<<<
 *     if newstyle_available():
 *         PyBuffer_FillInfo(&pybuf, astr, ptr, s, readonly, PyBUF_SIMPLE)
 */
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_37));
  __pyx_v_astr = __pyx_kp_s_37;

  /* "buffers.pxd":212
 *     cdef Py_ssize_t *shape = [s]
 *     cdef str astr=""
 *     if newstyle_available():             # <<<<<<<<<<<<<<
 *         PyBuffer_FillInfo(&pybuf, astr, ptr, s, readonly, PyBUF_SIMPLE)
 *         pybuf.format = "B"
 */
  __pyx_t_2 = __pyx_f_7buffers_newstyle_available();
  if (__pyx_t_2) {

    /* "buffers.pxd":213
 *     cdef str astr=""
 *     if newstyle_available():
 *         PyBuffer_FillInfo(&pybuf, astr, ptr, s, readonly, PyBUF_SIMPLE)             # <<<<<<<<<<<<<<
 *         pybuf.format = "B"
 *         pybuf.shape = shape
 */
    __pyx_t_2 = PyBuffer_FillInfo((&__pyx_v_pybuf), ((PyObject *)__pyx_v_astr), __pyx_v_ptr, __pyx_v_s, __pyx_v_readonly, PyBUF_SIMPLE); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "buffers.pxd":214
 *     if newstyle_available():
 *         PyBuffer_FillInfo(&pybuf, astr, ptr, s, readonly, PyBUF_SIMPLE)
 *         pybuf.format = "B"             # <<<<<<<<<<<<<<
 *         pybuf.shape = shape
 *         return PyMemoryView_FromBuffer(&pybuf)
 */
    __pyx_v_pybuf.format = __pyx_k__B;

    /* "buffers.pxd":215
 *         PyBuffer_FillInfo(&pybuf, astr, ptr, s, readonly, PyBUF_SIMPLE)
 *         pybuf.format = "B"
 *         pybuf.shape = shape             # <<<<<<<<<<<<<<
 *         return PyMemoryView_FromBuffer(&pybuf)
 *     else:
 */
    __pyx_v_pybuf.shape = __pyx_v_shape;

    /* "buffers.pxd":216
 *         pybuf.format = "B"
 *         pybuf.shape = shape
 *         return PyMemoryView_FromBuffer(&pybuf)             # <<<<<<<<<<<<<<
 *     else:
 *         raise NotImplementedError("New style buffers not available.")
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyMemoryView_FromBuffer((&__pyx_v_pybuf)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "buffers.pxd":218
 *         return PyMemoryView_FromBuffer(&pybuf)
 *     else:
 *         raise NotImplementedError("New style buffers not available.")             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_3 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_39), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("buffers.frombuffer_3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_astr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "buffers.pxd":221
 * 
 * 
 * cdef inline object frombuffer_2(void *ptr, Py_ssize_t s, int readonly):             # <<<<<<<<<<<<<<
 *     """Python 2 version of frombuffer.
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_2(void *__pyx_v_ptr, Py_ssize_t __pyx_v_s, int __pyx_v_readonly) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("frombuffer_2");

  /* "buffers.pxd":227
 *     """
 * 
 *     if oldstyle_available():             # <<<<<<<<<<<<<<
 *         if readonly:
 *             return PyBuffer_FromMemory(ptr, s)
 */
  __pyx_t_1 = __pyx_f_7buffers_oldstyle_available();
  if (__pyx_t_1) {

    /* "buffers.pxd":228
 * 
 *     if oldstyle_available():
 *         if readonly:             # <<<<<<<<<<<<<<
 *             return PyBuffer_FromMemory(ptr, s)
 *         else:
 */
    if (__pyx_v_readonly) {

      /* "buffers.pxd":229
 *     if oldstyle_available():
 *         if readonly:
 *             return PyBuffer_FromMemory(ptr, s)             # <<<<<<<<<<<<<<
 *         else:
 *             return PyBuffer_FromReadWriteMemory(ptr, s)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyBuffer_FromMemory(__pyx_v_ptr, __pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "buffers.pxd":231
 *             return PyBuffer_FromMemory(ptr, s)
 *         else:
 *             return PyBuffer_FromReadWriteMemory(ptr, s)             # <<<<<<<<<<<<<<
 *     else:
 *         raise NotImplementedError("Old style buffers not available.")
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyBuffer_FromReadWriteMemory(__pyx_v_ptr, __pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "buffers.pxd":233
 *             return PyBuffer_FromReadWriteMemory(ptr, s)
 *     else:
 *         raise NotImplementedError("Old style buffers not available.")             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_41), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("buffers.frombuffer_2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "buffers.pxd":236
 * 
 * 
 * cdef inline object frombuffer(void *ptr, Py_ssize_t s, int readonly):             # <<<<<<<<<<<<<<
 *     """Create a Python Buffer/View of a C array.
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer(void *__pyx_v_ptr, Py_ssize_t __pyx_v_s, int __pyx_v_readonly) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("frombuffer");

  /* "buffers.pxd":253
 *     """
 *     # oldstyle first priority for now
 *     if oldstyle_available():             # <<<<<<<<<<<<<<
 *         return frombuffer_2(ptr, s, readonly)
 *     else:
 */
  __pyx_t_1 = __pyx_f_7buffers_oldstyle_available();
  if (__pyx_t_1) {

    /* "buffers.pxd":254
 *     # oldstyle first priority for now
 *     if oldstyle_available():
 *         return frombuffer_2(ptr, s, readonly)             # <<<<<<<<<<<<<<
 *     else:
 *         return frombuffer_3(ptr, s, readonly)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_f_7buffers_frombuffer_2(__pyx_v_ptr, __pyx_v_s, __pyx_v_readonly); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "buffers.pxd":256
 *         return frombuffer_2(ptr, s, readonly)
 *     else:
 *         return frombuffer_3(ptr, s, readonly)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __pyx_f_7buffers_frombuffer_3(__pyx_v_ptr, __pyx_v_s, __pyx_v_readonly); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("buffers.frombuffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "buffers.pxd":259
 * 
 * 
 * cdef inline object frombuffer_r(void *ptr, Py_ssize_t s):             # <<<<<<<<<<<<<<
 *     """Wrapper for readonly view frombuffer."""
 *     return frombuffer(ptr, s, 1)
 */

static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_r(void *__pyx_v_ptr, Py_ssize_t __pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("frombuffer_r");

  /* "buffers.pxd":261
 * cdef inline object frombuffer_r(void *ptr, Py_ssize_t s):
 *     """Wrapper for readonly view frombuffer."""
 *     return frombuffer(ptr, s, 1)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7buffers_frombuffer(__pyx_v_ptr, __pyx_v_s, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("buffers.frombuffer_r", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "buffers.pxd":264
 * 
 * 
 * cdef inline object frombuffer_w(void *ptr, Py_ssize_t s):             # <<<<<<<<<<<<<<
 *     """Wrapper for writable view frombuffer."""
 *     return frombuffer(ptr, s, 0)
 */

static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_w(void *__pyx_v_ptr, Py_ssize_t __pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("frombuffer_w");

  /* "buffers.pxd":266
 * cdef inline object frombuffer_w(void *ptr, Py_ssize_t s):
 *     """Wrapper for writable view frombuffer."""
 *     return frombuffer(ptr, s, 0)             # <<<<<<<<<<<<<<
 * 
 * #------------------------------------------------------------------------------
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7buffers_frombuffer(__pyx_v_ptr, __pyx_v_s, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("buffers.frombuffer_w", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "buffers.pxd":273
 * #------------------------------------------------------------------------------
 * 
 * cdef inline object viewfromobject(object obj, int readonly):             # <<<<<<<<<<<<<<
 *     """Construct a Python Buffer/View object from another Python object.
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_7buffers_viewfromobject(PyObject *__pyx_v_obj, int __pyx_v_readonly) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("viewfromobject");

  /* "buffers.pxd":289
 *     Buffer/View of the original object.
 *     """
 *     if not memoryview_available():             # <<<<<<<<<<<<<<
 *         if readonly:
 *             return PyBuffer_FromObject(obj, 0, Py_END_OF_BUFFER)
 */
  __pyx_t_1 = (!__pyx_f_7buffers_memoryview_available());
  if (__pyx_t_1) {

    /* "buffers.pxd":290
 *     """
 *     if not memoryview_available():
 *         if readonly:             # <<<<<<<<<<<<<<
 *             return PyBuffer_FromObject(obj, 0, Py_END_OF_BUFFER)
 *         else:
 */
    if (__pyx_v_readonly) {

      /* "buffers.pxd":291
 *     if not memoryview_available():
 *         if readonly:
 *             return PyBuffer_FromObject(obj, 0, Py_END_OF_BUFFER)             # <<<<<<<<<<<<<<
 *         else:
 *             return PyBuffer_FromReadWriteObject(obj, 0, Py_END_OF_BUFFER)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyBuffer_FromObject(__pyx_v_obj, 0, Py_END_OF_BUFFER); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "buffers.pxd":293
 *             return PyBuffer_FromObject(obj, 0, Py_END_OF_BUFFER)
 *         else:
 *             return PyBuffer_FromReadWriteObject(obj, 0, Py_END_OF_BUFFER)             # <<<<<<<<<<<<<<
 *     else:
 *         return PyMemoryView_FromObject(obj)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyBuffer_FromReadWriteObject(__pyx_v_obj, 0, Py_END_OF_BUFFER); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L0;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "buffers.pxd":295
 *             return PyBuffer_FromReadWriteObject(obj, 0, Py_END_OF_BUFFER)
 *     else:
 *         return PyMemoryView_FromObject(obj)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyMemoryView_FromObject(__pyx_v_obj); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("buffers.viewfromobject", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "buffers.pxd":298
 * 
 * 
 * cdef inline object viewfromobject_r(object obj):             # <<<<<<<<<<<<<<
 *     """Wrapper for readonly viewfromobject."""
 *     return viewfromobject(obj, 1)
 */

static CYTHON_INLINE PyObject *__pyx_f_7buffers_viewfromobject_r(PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("viewfromobject_r");

  /* "buffers.pxd":300
 * cdef inline object viewfromobject_r(object obj):
 *     """Wrapper for readonly viewfromobject."""
 *     return viewfromobject(obj, 1)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7buffers_viewfromobject(__pyx_v_obj, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("buffers.viewfromobject_r", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "buffers.pxd":303
 * 
 * 
 * cdef inline object viewfromobject_w(object obj):             # <<<<<<<<<<<<<<
 *     """Wrapper for writable viewfromobject."""
 *     return viewfromobject(obj, 0)
 */

static CYTHON_INLINE PyObject *__pyx_f_7buffers_viewfromobject_w(PyObject *__pyx_v_obj) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("viewfromobject_w");

  /* "buffers.pxd":305
 * cdef inline object viewfromobject_w(object obj):
 *     """Wrapper for writable viewfromobject."""
 *     return viewfromobject(obj, 0)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_7buffers_viewfromobject(__pyx_v_obj, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("buffers.viewfromobject_w", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_3zmq_4core_6socket_Socket __pyx_vtable_3zmq_4core_6socket_Socket;

static PyObject *__pyx_tp_new_3zmq_4core_6socket_Socket(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_3zmq_4core_6socket_Socket *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_3zmq_4core_6socket_Socket *)o);
  p->__pyx_vtab = __pyx_vtabptr_3zmq_4core_6socket_Socket;
  p->context = ((struct __pyx_obj_3zmq_4core_7context_Context *)Py_None); Py_INCREF(Py_None);
  p->_attrs = ((PyObject*)Py_None); Py_INCREF(Py_None);
  if (__pyx_pf_3zmq_4core_6socket_6Socket___cinit__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_3zmq_4core_6socket_Socket(PyObject *o) {
  struct __pyx_obj_3zmq_4core_6socket_Socket *p = (struct __pyx_obj_3zmq_4core_6socket_Socket *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_3zmq_4core_6socket_6Socket_2__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(((PyObject *)p->context));
  Py_XDECREF(((PyObject *)p->_attrs));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_3zmq_4core_6socket_Socket(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_3zmq_4core_6socket_Socket *p = (struct __pyx_obj_3zmq_4core_6socket_Socket *)o;
  if (p->context) {
    e = (*v)(((PyObject*)p->context), a); if (e) return e;
  }
  if (p->_attrs) {
    e = (*v)(p->_attrs, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_3zmq_4core_6socket_Socket(PyObject *o) {
  struct __pyx_obj_3zmq_4core_6socket_Socket *p = (struct __pyx_obj_3zmq_4core_6socket_Socket *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->context);
  p->context = ((struct __pyx_obj_3zmq_4core_7context_Context *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_attrs);
  p->_attrs = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_tp_getattro_3zmq_4core_6socket_Socket(PyObject *o, PyObject *n) {
  PyObject *v = PyObject_GenericGetAttr(o, n);
  if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
    PyErr_Clear();
    v = __pyx_pf_3zmq_4core_6socket_6Socket_11__getattr__(o, n);
  }
  return v;
}

static int __pyx_tp_setattro_3zmq_4core_6socket_Socket(PyObject *o, PyObject *n, PyObject *v) {
  if (v) {
    return __pyx_pf_3zmq_4core_6socket_6Socket_10__setattr__(o, n, v);
  }
  else {
    return PyObject_GenericSetAttr(o, n, 0);
  }
}

static PyObject *__pyx_getprop_3zmq_4core_6socket_6Socket_socket_type(PyObject *o, void *x) {
  return __pyx_pf_3zmq_4core_6socket_6Socket_11socket_type___get__(o);
}

static int __pyx_setprop_3zmq_4core_6socket_6Socket_socket_type(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_3zmq_4core_6socket_6Socket_11socket_type_1__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_3zmq_4core_6socket_6Socket_context(PyObject *o, void *x) {
  return __pyx_pf_3zmq_4core_6socket_6Socket_7context___get__(o);
}

static int __pyx_setprop_3zmq_4core_6socket_6Socket_context(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_3zmq_4core_6socket_6Socket_7context_1__set__(o, v);
  }
  else {
    return __pyx_pf_3zmq_4core_6socket_6Socket_7context_2__del__(o);
  }
}

static PyObject *__pyx_getprop_3zmq_4core_6socket_6Socket__closed(PyObject *o, void *x) {
  return __pyx_pf_3zmq_4core_6socket_6Socket_7_closed___get__(o);
}

static int __pyx_setprop_3zmq_4core_6socket_6Socket__closed(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_3zmq_4core_6socket_6Socket_7_closed_1__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_3zmq_4core_6socket_Socket[] = {
  {__Pyx_NAMESTR("__del__"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_1__del__, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_1__del__)},
  {__Pyx_NAMESTR("closed"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_4closed, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_5close, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_5close)},
  {__Pyx_NAMESTR("setsockopt"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_6setsockopt, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_6setsockopt)},
  {__Pyx_NAMESTR("getsockopt"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_7getsockopt, METH_O, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_7getsockopt)},
  {__Pyx_NAMESTR("setsockopt_unicode"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_8setsockopt_unicode, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_8setsockopt_unicode)},
  {__Pyx_NAMESTR("getsockopt_unicode"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_9getsockopt_unicode, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_9getsockopt_unicode)},
  {__Pyx_NAMESTR("__getattr__"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_11__getattr__, METH_O|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_11__getattr__)},
  {__Pyx_NAMESTR("bind"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_12bind, METH_O, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_12bind)},
  {__Pyx_NAMESTR("bind_to_random_port"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_13bind_to_random_port, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_13bind_to_random_port)},
  {__Pyx_NAMESTR("connect"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_14connect, METH_O, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_14connect)},
  {__Pyx_NAMESTR("send"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_15send, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_15send)},
  {__Pyx_NAMESTR("recv"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_16recv, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_16recv)},
  {__Pyx_NAMESTR("send_multipart"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_17send_multipart, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_17send_multipart)},
  {__Pyx_NAMESTR("recv_multipart"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_18recv_multipart, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_18recv_multipart)},
  {__Pyx_NAMESTR("send_unicode"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_19send_unicode, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_19send_unicode)},
  {__Pyx_NAMESTR("recv_unicode"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_20recv_unicode, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_20recv_unicode)},
  {__Pyx_NAMESTR("send_pyobj"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_21send_pyobj, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_21send_pyobj)},
  {__Pyx_NAMESTR("recv_pyobj"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_22recv_pyobj, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_22recv_pyobj)},
  {__Pyx_NAMESTR("send_json"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_23send_json, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_23send_json)},
  {__Pyx_NAMESTR("recv_json"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_24recv_json, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_24recv_json)},
  {__Pyx_NAMESTR("poll"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_25poll, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_25poll)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_3zmq_4core_6socket_Socket[] = {
  {(char *)"socket_type", __pyx_getprop_3zmq_4core_6socket_6Socket_socket_type, __pyx_setprop_3zmq_4core_6socket_6Socket_socket_type, 0, 0},
  {(char *)"context", __pyx_getprop_3zmq_4core_6socket_6Socket_context, __pyx_setprop_3zmq_4core_6socket_6Socket_context, 0, 0},
  {(char *)"_closed", __pyx_getprop_3zmq_4core_6socket_6Socket__closed, __pyx_setprop_3zmq_4core_6socket_6Socket__closed, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Socket = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Socket = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Socket = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Socket = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_3zmq_4core_6socket_Socket = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("zmq.core.socket.Socket"), /*tp_name*/
  sizeof(struct __pyx_obj_3zmq_4core_6socket_Socket), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_3zmq_4core_6socket_Socket, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Socket, /*tp_as_number*/
  &__pyx_tp_as_sequence_Socket, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Socket, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  __pyx_tp_getattro_3zmq_4core_6socket_Socket, /*tp_getattro*/
  __pyx_tp_setattro_3zmq_4core_6socket_Socket, /*tp_setattro*/
  &__pyx_tp_as_buffer_Socket, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Socket(context, socket_type)\n\n    A 0MQ socket.\n\n    These objects will generally be constructed via the socket() method of a Context object.\n    \n    Note: 0MQ Sockets are *not* threadsafe. **DO NOT** share them across threads.\n    \n    Parameters\n    ----------\n    context : Context\n        The 0MQ Context this Socket belongs to.\n    socket_type : int\n        The socket type, which can be any of the 0MQ socket types: \n        REQ, REP, PUB, SUB, PAIR, XREQ, DEALER, XREP, ROUTER, PULL, PUSH, XPUB, XSUB.\n    \n    See Also\n    --------\n    .Context.socket : method for creating a socket bound to a Context.\n    "), /*tp_doc*/
  __pyx_tp_traverse_3zmq_4core_6socket_Socket, /*tp_traverse*/
  __pyx_tp_clear_3zmq_4core_6socket_Socket, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_3zmq_4core_6socket_Socket, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_3zmq_4core_6socket_Socket, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_3zmq_4core_6socket_6Socket_3__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_3zmq_4core_6socket_Socket, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

char* __pyx_import_star_type_names[] = {
  "__pyx_opt_args_3zmq_4core_6socket__send_copy",
  "Socket",
  "__pyx_opt_args_3zmq_4core_6socket_6Socket_send",
  "const_void_ptr",
  "zmq_pollitem_t",
  "Context",
  "fd_t",
  "zmq_free_fn",
  "__pyx_opt_args_3zmq_4core_6socket__recv_message",
  "zmq_msg_t",
  "int64_t",
  "__pyx_opt_args_3zmq_4core_6socket_6Socket_recv",
  "__pyx_opt_args_3zmq_4core_6socket__recv_copy",
  "Message",
  "__pyx_opt_args_3zmq_4core_6socket__send_message",
  "Py_ssize_t",
  0
};

static int __pyx_import_star_set(PyObject *o, PyObject* py_name, char *name) {
  char** type_name = __pyx_import_star_type_names;
  while (*type_name) {
    if (__Pyx_StrEq(name, *type_name)) {
      PyErr_Format(PyExc_TypeError, "Cannot overwrite C type %s", name);
      goto bad;
    }
    type_name++;
  }
  if (0);
  else {
    if (PyObject_SetAttr(__pyx_m, py_name, o) < 0) goto bad;
  }
  return 0;
  bad:
  return -1;
}


/* import_all_from is an unexposed function from ceval.c */

static int
__Pyx_import_all_from(PyObject *locals, PyObject *v)
{
    PyObject *all = __Pyx_GetAttrString(v, "__all__");
    PyObject *dict, *name, *value;
    int skip_leading_underscores = 0;
    int pos, err;

    if (all == NULL) {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError))
            return -1; /* Unexpected error */
        PyErr_Clear();
        dict = __Pyx_GetAttrString(v, "__dict__");
        if (dict == NULL) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError))
                return -1;
            PyErr_SetString(PyExc_ImportError,
            "from-import-* object has no __dict__ and no __all__");
            return -1;
        }
#if PY_MAJOR_VERSION < 3
        all = PyObject_CallMethod(dict, (char *)"keys", NULL);
#else
        all = PyMapping_Keys(dict);
#endif
        Py_DECREF(dict);
        if (all == NULL)
            return -1;
        skip_leading_underscores = 1;
    }

    for (pos = 0, err = 0; ; pos++) {
        name = PySequence_GetItem(all, pos);
        if (name == NULL) {
            if (!PyErr_ExceptionMatches(PyExc_IndexError))
                err = -1;
            else
                PyErr_Clear();
            break;
        }
        if (skip_leading_underscores &&
#if PY_MAJOR_VERSION < 3
            PyString_Check(name) &&
            PyString_AS_STRING(name)[0] == '_')
#else
            PyUnicode_Check(name) &&
            PyUnicode_AS_UNICODE(name)[0] == '_')
#endif
        {
            Py_DECREF(name);
            continue;
        }
        value = PyObject_GetAttr(v, name);
        if (value == NULL)
            err = -1;
        else if (PyDict_CheckExact(locals))
            err = PyDict_SetItem(locals, name, value);
        else
            err = PyObject_SetItem(locals, name, value);
        Py_DECREF(name);
        Py_XDECREF(value);
        if (err != 0)
            break;
    }
    Py_DECREF(all);
    return err;
}


static int __pyx_import_star(PyObject* m) {

    int i;
    int ret = -1;
    char* s;
    PyObject *locals = 0;
    PyObject *list = 0;
#if PY_MAJOR_VERSION >= 3
    PyObject *utf8_name = 0;
#endif
    PyObject *name;
    PyObject *item;

    locals = PyDict_New();              if (!locals) goto bad;
    if (__Pyx_import_all_from(locals, m) < 0) goto bad;
    list = PyDict_Items(locals);        if (!list) goto bad;

    for(i=0; i<PyList_GET_SIZE(list); i++) {
        name = PyTuple_GET_ITEM(PyList_GET_ITEM(list, i), 0);
        item = PyTuple_GET_ITEM(PyList_GET_ITEM(list, i), 1);
#if PY_MAJOR_VERSION >= 3
        utf8_name = PyUnicode_AsUTF8String(name);
        if (!utf8_name) goto bad;
        s = PyBytes_AS_STRING(utf8_name);
        if (__pyx_import_star_set(item, name, s) < 0) goto bad;
        Py_DECREF(utf8_name); utf8_name = 0;
#else
        s = PyString_AsString(name);
        if (!s) goto bad;
        if (__pyx_import_star_set(item, name, s) < 0) goto bad;
#endif
    }
    ret = 0;

bad:
    Py_XDECREF(locals);
    Py_XDECREF(list);
#if PY_MAJOR_VERSION >= 3
    Py_XDECREF(utf8_name);
#endif
    return ret;
}


#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("socket"),
    __Pyx_DOCSTR(__pyx_k_42), /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
  {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
  {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
  {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
  {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0},
  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0},
  {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0},
  {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0},
  {&__pyx_kp_s_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 0},
  {&__pyx_kp_s_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 0, 1, 0},
  {&__pyx_kp_s_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 1, 0},
  {&__pyx_kp_s_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 0, 1, 0},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_kp_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 0},
  {&__pyx_n_s_43, __pyx_k_43, sizeof(__pyx_k_43), 0, 0, 1, 1},
  {&__pyx_n_s_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 0, 1, 1},
  {&__pyx_n_s_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 1, 1},
  {&__pyx_n_s_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 1, 1},
  {&__pyx_n_s_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 1, 1},
  {&__pyx_n_s_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 0, 1, 1},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
  {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
  {&__pyx_n_s__AttributeError, __pyx_k__AttributeError, sizeof(__pyx_k__AttributeError), 0, 0, 1, 1},
  {&__pyx_n_s__B, __pyx_k__B, sizeof(__pyx_k__B), 0, 0, 1, 1},
  {&__pyx_n_s__ENOTSOCK, __pyx_k__ENOTSOCK, sizeof(__pyx_k__ENOTSOCK), 0, 0, 1, 1},
  {&__pyx_n_s__ENOTSUP, __pyx_k__ENOTSUP, sizeof(__pyx_k__ENOTSUP), 0, 0, 1, 1},
  {&__pyx_n_s__ImportError, __pyx_k__ImportError, sizeof(__pyx_k__ImportError), 0, 0, 1, 1},
  {&__pyx_n_s__NotImplementedError, __pyx_k__NotImplementedError, sizeof(__pyx_k__NotImplementedError), 0, 0, 1, 1},
  {&__pyx_n_s__POLLERR, __pyx_k__POLLERR, sizeof(__pyx_k__POLLERR), 0, 0, 1, 1},
  {&__pyx_n_s__POLLIN, __pyx_k__POLLIN, sizeof(__pyx_k__POLLIN), 0, 0, 1, 1},
  {&__pyx_n_s__Poller, __pyx_k__Poller, sizeof(__pyx_k__Poller), 0, 0, 1, 1},
  {&__pyx_n_s__SNDMORE, __pyx_k__SNDMORE, sizeof(__pyx_k__SNDMORE), 0, 0, 1, 1},
  {&__pyx_n_s__Socket, __pyx_k__Socket, sizeof(__pyx_k__Socket), 0, 0, 1, 1},
  {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
  {&__pyx_n_s__ZMQBindError, __pyx_k__ZMQBindError, sizeof(__pyx_k__ZMQBindError), 0, 0, 1, 1},
  {&__pyx_n_s__ZMQError, __pyx_k__ZMQError, sizeof(__pyx_k__ZMQError), 0, 0, 1, 1},
  {&__pyx_n_s____all__, __pyx_k____all__, sizeof(__pyx_k____all__), 0, 0, 1, 1},
  {&__pyx_n_s____class__, __pyx_k____class__, sizeof(__pyx_k____class__), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____module__, __pyx_k____module__, sizeof(__pyx_k____module__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s___handle, __pyx_k___handle, sizeof(__pyx_k___handle), 0, 0, 1, 1},
  {&__pyx_n_s__addr, __pyx_k__addr, sizeof(__pyx_k__addr), 0, 0, 1, 1},
  {&__pyx_n_s__basestring, __pyx_k__basestring, sizeof(__pyx_k__basestring), 0, 0, 1, 1},
  {&__pyx_n_s__bind, __pyx_k__bind, sizeof(__pyx_k__bind), 0, 0, 1, 1},
  {&__pyx_n_s__buffer, __pyx_k__buffer, sizeof(__pyx_k__buffer), 0, 0, 1, 1},
  {&__pyx_n_s__bytes, __pyx_k__bytes, sizeof(__pyx_k__bytes), 0, 0, 1, 1},
  {&__pyx_n_s__bytes_sockopts, __pyx_k__bytes_sockopts, sizeof(__pyx_k__bytes_sockopts), 0, 0, 1, 1},
  {&__pyx_n_s__cPickle, __pyx_k__cPickle, sizeof(__pyx_k__cPickle), 0, 0, 1, 1},
  {&__pyx_n_s__char, __pyx_k__char, sizeof(__pyx_k__char), 0, 0, 1, 1},
  {&__pyx_n_s__close, __pyx_k__close, sizeof(__pyx_k__close), 0, 0, 1, 1},
  {&__pyx_n_s__closed, __pyx_k__closed, sizeof(__pyx_k__closed), 0, 0, 1, 1},
  {&__pyx_n_s__codecs, __pyx_k__codecs, sizeof(__pyx_k__codecs), 0, 0, 1, 1},
  {&__pyx_n_s__constants, __pyx_k__constants, sizeof(__pyx_k__constants), 0, 0, 1, 1},
  {&__pyx_n_s__context, __pyx_k__context, sizeof(__pyx_k__context), 0, 0, 1, 1},
  {&__pyx_n_s__copy, __pyx_k__copy, sizeof(__pyx_k__copy), 0, 0, 1, 1},
  {&__pyx_n_s__copy_mod, __pyx_k__copy_mod, sizeof(__pyx_k__copy_mod), 0, 0, 1, 1},
  {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1},
  {&__pyx_n_s__decode, __pyx_k__decode, sizeof(__pyx_k__decode), 0, 0, 1, 1},
  {&__pyx_n_s__dtype, __pyx_k__dtype, sizeof(__pyx_k__dtype), 0, 0, 1, 1},
  {&__pyx_n_s__dumps, __pyx_k__dumps, sizeof(__pyx_k__dumps), 0, 0, 1, 1},
  {&__pyx_n_s__encode, __pyx_k__encode, sizeof(__pyx_k__encode), 0, 0, 1, 1},
  {&__pyx_n_s__encoding, __pyx_k__encoding, sizeof(__pyx_k__encoding), 0, 0, 1, 1},
  {&__pyx_n_s__flags, __pyx_k__flags, sizeof(__pyx_k__flags), 0, 0, 1, 1},
  {&__pyx_n_s__getsockopt, __pyx_k__getsockopt, sizeof(__pyx_k__getsockopt), 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__itemsize, __pyx_k__itemsize, sizeof(__pyx_k__itemsize), 0, 0, 1, 1},
  {&__pyx_n_s__jsonapi, __pyx_k__jsonapi, sizeof(__pyx_k__jsonapi), 0, 0, 1, 1},
  {&__pyx_n_s__jsonmod, __pyx_k__jsonmod, sizeof(__pyx_k__jsonmod), 0, 0, 1, 1},
  {&__pyx_n_s__linger, __pyx_k__linger, sizeof(__pyx_k__linger), 0, 0, 1, 1},
  {&__pyx_n_s__loads, __pyx_k__loads, sizeof(__pyx_k__loads), 0, 0, 1, 1},
  {&__pyx_n_s__max_port, __pyx_k__max_port, sizeof(__pyx_k__max_port), 0, 0, 1, 1},
  {&__pyx_n_s__max_tries, __pyx_k__max_tries, sizeof(__pyx_k__max_tries), 0, 0, 1, 1},
  {&__pyx_n_s__min_port, __pyx_k__min_port, sizeof(__pyx_k__min_port), 0, 0, 1, 1},
  {&__pyx_n_s__msg_parts, __pyx_k__msg_parts, sizeof(__pyx_k__msg_parts), 0, 0, 1, 1},
  {&__pyx_n_s__obj, __pyx_k__obj, sizeof(__pyx_k__obj), 0, 0, 1, 1},
  {&__pyx_n_s__option, __pyx_k__option, sizeof(__pyx_k__option), 0, 0, 1, 1},
  {&__pyx_n_s__optval, __pyx_k__optval, sizeof(__pyx_k__optval), 0, 0, 1, 1},
  {&__pyx_n_s__pickle, __pyx_k__pickle, sizeof(__pyx_k__pickle), 0, 0, 1, 1},
  {&__pyx_n_s__poll, __pyx_k__poll, sizeof(__pyx_k__poll), 0, 0, 1, 1},
  {&__pyx_n_s__prefix, __pyx_k__prefix, sizeof(__pyx_k__prefix), 0, 0, 1, 1},
  {&__pyx_n_s__property, __pyx_k__property, sizeof(__pyx_k__property), 0, 0, 1, 1},
  {&__pyx_n_s__protocol, __pyx_k__protocol, sizeof(__pyx_k__protocol), 0, 0, 1, 1},
  {&__pyx_n_s__random, __pyx_k__random, sizeof(__pyx_k__random), 0, 0, 1, 1},
  {&__pyx_n_s__randrange, __pyx_k__randrange, sizeof(__pyx_k__randrange), 0, 0, 1, 1},
  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
  {&__pyx_n_s__recv, __pyx_k__recv, sizeof(__pyx_k__recv), 0, 0, 1, 1},
  {&__pyx_n_s__register, __pyx_k__register, sizeof(__pyx_k__register), 0, 0, 1, 1},
  {&__pyx_n_s__send, __pyx_k__send, sizeof(__pyx_k__send), 0, 0, 1, 1},
  {&__pyx_n_s__setsockopt, __pyx_k__setsockopt, sizeof(__pyx_k__setsockopt), 0, 0, 1, 1},
  {&__pyx_n_s__socket_type, __pyx_k__socket_type, sizeof(__pyx_k__socket_type), 0, 0, 1, 1},
  {&__pyx_n_s__struct, __pyx_k__struct, sizeof(__pyx_k__struct), 0, 0, 1, 1},
  {&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1},
  {&__pyx_n_s__time, __pyx_k__time, sizeof(__pyx_k__time), 0, 0, 1, 1},
  {&__pyx_n_s__timeout, __pyx_k__timeout, sizeof(__pyx_k__timeout), 0, 0, 1, 1},
  {&__pyx_n_s__track, __pyx_k__track, sizeof(__pyx_k__track), 0, 0, 1, 1},
  {&__pyx_n_s__tracker, __pyx_k__tracker, sizeof(__pyx_k__tracker), 0, 0, 1, 1},
  {&__pyx_n_s__typecode, __pyx_k__typecode, sizeof(__pyx_k__typecode), 0, 0, 1, 1},
  {&__pyx_n_s__u, __pyx_k__u, sizeof(__pyx_k__u), 0, 0, 1, 1},
  {&__pyx_n_s__unicode, __pyx_k__unicode, sizeof(__pyx_k__unicode), 0, 0, 1, 1},
  {&__pyx_n_s__upper, __pyx_k__upper, sizeof(__pyx_k__upper), 0, 0, 1, 1},
  {&__pyx_n_s__xrange, __pyx_k__xrange, sizeof(__pyx_k__xrange), 0, 0, 1, 1},
  {&__pyx_n_s__zmq, __pyx_k__zmq, sizeof(__pyx_k__zmq), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_property = __Pyx_GetName(__pyx_b, __pyx_n_s__property); if (!__pyx_builtin_property) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_AttributeError = __Pyx_GetName(__pyx_b, __pyx_n_s__AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if PY_MAJOR_VERSION >= 3
  __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #else
  __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ImportError = __Pyx_GetName(__pyx_b, __pyx_n_s__ImportError); if (!__pyx_builtin_ImportError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_NotImplementedError = __Pyx_GetName(__pyx_b, __pyx_n_s__NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants");

  /* "zmq/core/socket.pyx":285
 *         _check_closed(self, True)
 *         if isinstance(optval, unicode):
 *             raise TypeError("unicode not allowed, use setsockopt_unicode")             # <<<<<<<<<<<<<<
 * 
 *         if option in constants.bytes_sockopts:
 */
  __pyx_k_tuple_3 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_3));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
  PyTuple_SET_ITEM(__pyx_k_tuple_3, 0, ((PyObject *)__pyx_kp_s_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_3));

  /* "zmq/core/socket.pyx":407
 *         """
 *         if not isinstance(optval, unicode):
 *             raise TypeError("unicode strings only")             # <<<<<<<<<<<<<<
 *         return self.setsockopt(option, optval.encode(encoding))
 * 
 */
  __pyx_k_tuple_8 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_8));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_7));
  PyTuple_SET_ITEM(__pyx_k_tuple_8, 0, ((PyObject *)__pyx_kp_s_7));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_7));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_8));

  /* "zmq/core/socket.pyx":482
 *         _check_closed(self, True)
 *         if isinstance(addr, unicode):
 *             addr = addr.encode('utf-8')             # <<<<<<<<<<<<<<
 *         if not isinstance(addr, bytes):
 *             raise TypeError('expected str, got: %r' % addr)
 */
  __pyx_k_tuple_12 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_12));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
  PyTuple_SET_ITEM(__pyx_k_tuple_12, 0, ((PyObject *)__pyx_kp_s_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_12));

  /* "zmq/core/socket.pyx":525
 *             else:
 *                 return port
 *         raise ZMQBindError("Could not bind socket to random port.")             # <<<<<<<<<<<<<<
 * 
 *     def connect(self, addr):
 */
  __pyx_k_tuple_16 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_16));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_15));
  PyTuple_SET_ITEM(__pyx_k_tuple_16, 0, ((PyObject *)__pyx_kp_s_15));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_15));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_16));

  /* "zmq/core/socket.pyx":545
 *         _check_closed(self, True)
 *         if isinstance(addr, unicode):
 *             addr = addr.encode('utf-8')             # <<<<<<<<<<<<<<
 *         if not isinstance(addr, bytes):
 *             raise TypeError('expected str, got: %r' % addr)
 */
  __pyx_k_tuple_17 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_17));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
  PyTuple_SET_ITEM(__pyx_k_tuple_17, 0, ((PyObject *)__pyx_kp_s_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_17));

  /* "zmq/core/socket.pyx":599
 * 
 *         if isinstance(data, unicode):
 *             raise TypeError("unicode not allowed, use send_unicode")             # <<<<<<<<<<<<<<
 * 
 *         if copy:
 */
  __pyx_k_tuple_21 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_21));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
  PyTuple_SET_ITEM(__pyx_k_tuple_21, 0, ((PyObject *)__pyx_kp_s_20));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21));

  /* "zmq/core/socket.pyx":610
 *             if isinstance(data, Message):
 *                 if track and not data.tracker:
 *                     raise ValueError('Not a tracked message')             # <<<<<<<<<<<<<<
 *                 msg = data
 *             else:
 */
  __pyx_k_tuple_23 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_23));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_22));
  PyTuple_SET_ITEM(__pyx_k_tuple_23, 0, ((PyObject *)__pyx_kp_s_22));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_22));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_23));

  /* "zmq/core/socket.pyx":743
 *         """
 *         if not isinstance(u, basestring):
 *             raise TypeError("unicode/str objects only")             # <<<<<<<<<<<<<<
 *         return self.send(u.encode(encoding), flags=flags, copy=copy)
 * 
 */
  __pyx_k_tuple_32 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_32));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_31));
  PyTuple_SET_ITEM(__pyx_k_tuple_32, 0, ((PyObject *)__pyx_kp_s_31));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_31));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_32));

  /* "zmq/core/socket.pyx":816
 *         """
 *         if jsonapi.jsonmod is None:
 *             raise ImportError('jsonlib{1,2}, json or simplejson library is required.')             # <<<<<<<<<<<<<<
 *         else:
 *             msg = jsonapi.dumps(obj)
 */
  __pyx_k_tuple_34 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_34));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_33));
  PyTuple_SET_ITEM(__pyx_k_tuple_34, 0, ((PyObject *)__pyx_kp_s_33));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_33));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_34));

  /* "zmq/core/socket.pyx":837
 *         """
 *         if jsonapi.jsonmod is None:
 *             raise ImportError('jsonlib{1,2}, json or simplejson library is required.')             # <<<<<<<<<<<<<<
 *         else:
 *             msg = self.recv(flags)
 */
  __pyx_k_tuple_35 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_35));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_33));
  PyTuple_SET_ITEM(__pyx_k_tuple_35, 0, ((PyObject *)__pyx_kp_s_33));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_33));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_35));

  /* "buffers.pxd":218
 *         return PyMemoryView_FromBuffer(&pybuf)
 *     else:
 *         raise NotImplementedError("New style buffers not available.")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_k_tuple_39 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_39)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_39));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_38));
  PyTuple_SET_ITEM(__pyx_k_tuple_39, 0, ((PyObject *)__pyx_kp_s_38));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_38));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_39));

  /* "buffers.pxd":233
 *             return PyBuffer_FromReadWriteMemory(ptr, s)
 *     else:
 *         raise NotImplementedError("Old style buffers not available.")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_k_tuple_41 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_41)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_41));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_40));
  PyTuple_SET_ITEM(__pyx_k_tuple_41, 0, ((PyObject *)__pyx_kp_s_40));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_40));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_41));
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_100 = PyInt_FromLong(100); if (unlikely(!__pyx_int_100)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_49152 = PyInt_FromLong(49152); if (unlikely(!__pyx_int_49152)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_65536 = PyInt_FromLong(65536); if (unlikely(!__pyx_int_65536)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initsocket(void); /*proto*/
PyMODINIT_FUNC initsocket(void)
#else
PyMODINIT_FUNC PyInit_socket(void); /*proto*/
PyMODINIT_FUNC PyInit_socket(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_socket(void)");
  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __pyx_binding_PyCFunctionType_USED
  if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("socket"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_42), 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  #if PY_MAJOR_VERSION < 3
  Py_INCREF(__pyx_m);
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_module_is_main_zmq__core__socket) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_3zmq_4core_6socket_Socket = &__pyx_vtable_3zmq_4core_6socket_Socket;
  __pyx_vtable_3zmq_4core_6socket_Socket.send = (PyObject *(*)(struct __pyx_obj_3zmq_4core_6socket_Socket *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send *__pyx_optional_args))__pyx_f_3zmq_4core_6socket_6Socket_send;
  __pyx_vtable_3zmq_4core_6socket_Socket.recv = (PyObject *(*)(struct __pyx_obj_3zmq_4core_6socket_Socket *, int __pyx_skip_dispatch, struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv *__pyx_optional_args))__pyx_f_3zmq_4core_6socket_6Socket_recv;
  if (PyType_Ready(&__pyx_type_3zmq_4core_6socket_Socket) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_3zmq_4core_6socket_Socket, "__setattr__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_3zmq_4core_6socket_6Socket_10__setattr__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_3zmq_4core_6socket_6Socket_10__setattr__.doc = __pyx_doc_3zmq_4core_6socket_6Socket_10__setattr__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_3zmq_4core_6socket_6Socket_10__setattr__;
    }
  }
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_3zmq_4core_6socket_Socket, "__getattr__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_3zmq_4core_6socket_6Socket_11__getattr__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_3zmq_4core_6socket_6Socket_11__getattr__.doc = __pyx_doc_3zmq_4core_6socket_6Socket_11__getattr__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_3zmq_4core_6socket_6Socket_11__getattr__;
    }
  }
  if (__Pyx_SetVtable(__pyx_type_3zmq_4core_6socket_Socket.tp_dict, __pyx_vtabptr_3zmq_4core_6socket_Socket) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Socket", (PyObject *)&__pyx_type_3zmq_4core_6socket_Socket) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_3zmq_4core_6socket_Socket = &__pyx_type_3zmq_4core_6socket_Socket;
  /*--- Type import code ---*/
  __pyx_ptype_3zmq_4core_7message_MessageTracker = __Pyx_ImportType("zmq.core.message", "MessageTracker", sizeof(struct __pyx_obj_3zmq_4core_7message_MessageTracker), 1); if (unlikely(!__pyx_ptype_3zmq_4core_7message_MessageTracker)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_3zmq_4core_7message_Message = __Pyx_ImportType("zmq.core.message", "Message", sizeof(struct __pyx_obj_3zmq_4core_7message_Message), 1); if (unlikely(!__pyx_ptype_3zmq_4core_7message_Message)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_3zmq_4core_7message_Message = (struct __pyx_vtabstruct_3zmq_4core_7message_Message*)__Pyx_GetVtable(__pyx_ptype_3zmq_4core_7message_Message->tp_dict); if (unlikely(!__pyx_vtabptr_3zmq_4core_7message_Message)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_3zmq_4core_7context_Context = __Pyx_ImportType("zmq.core.context", "Context", sizeof(struct __pyx_obj_3zmq_4core_7context_Context), 1); if (unlikely(!__pyx_ptype_3zmq_4core_7context_Context)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_3zmq_4core_7context_Context = (struct __pyx_vtabstruct_3zmq_4core_7context_Context*)__Pyx_GetVtable(__pyx_ptype_3zmq_4core_7context_Context->tp_dict); if (unlikely(!__pyx_vtabptr_3zmq_4core_7context_Context)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("zmq.core.message"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_1, "copy_zmq_msg_bytes", (void (**)(void))&__pyx_f_3zmq_4core_7message_copy_zmq_msg_bytes, "PyObject *(zmq_msg_t *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  /*--- Execution code ---*/

  /* "zmq/core/socket.pyx":48
 * #-----------------------------------------------------------------------------
 * 
 * import copy as copy_mod             # <<<<<<<<<<<<<<
 * import time
 * import sys
 */
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__copy), 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__copy_mod, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "zmq/core/socket.pyx":49
 * 
 * import copy as copy_mod
 * import time             # <<<<<<<<<<<<<<
 * import sys
 * import random
 */
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__time), 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__time, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "zmq/core/socket.pyx":50
 * import copy as copy_mod
 * import time
 * import sys             # <<<<<<<<<<<<<<
 * import random
 * import struct
 */
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sys, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "zmq/core/socket.pyx":51
 * import time
 * import sys
 * import random             # <<<<<<<<<<<<<<
 * import struct
 * import codecs
 */
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__random), 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__random, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "zmq/core/socket.pyx":52
 * import sys
 * import random
 * import struct             # <<<<<<<<<<<<<<
 * import codecs
 * 
 */
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__struct), 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__struct, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "zmq/core/socket.pyx":53
 * import random
 * import struct
 * import codecs             # <<<<<<<<<<<<<<
 * 
 * from zmq.utils import jsonapi
 */
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__codecs), 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__codecs, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "zmq/core/socket.pyx":55
 * import codecs
 * 
 * from zmq.utils import jsonapi             # <<<<<<<<<<<<<<
 * 
 * try:
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__jsonapi));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__jsonapi));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__jsonapi));
  __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s_43), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__jsonapi); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__jsonapi, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "zmq/core/socket.pyx":57
 * from zmq.utils import jsonapi
 * 
 * try:             # <<<<<<<<<<<<<<
 *     import cPickle
 *     pickle = cPickle
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "zmq/core/socket.pyx":58
 * 
 * try:
 *     import cPickle             # <<<<<<<<<<<<<<
 *     pickle = cPickle
 * except:
 */
      __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s__cPickle), 0, -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s__cPickle, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "zmq/core/socket.pyx":59
 * try:
 *     import cPickle
 *     pickle = cPickle             # <<<<<<<<<<<<<<
 * except:
 *     cPickle = None
 */
      __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__cPickle); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s__pickle, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L9_try_end;
    __pyx_L2_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "zmq/core/socket.pyx":60
 *     import cPickle
 *     pickle = cPickle
 * except:             # <<<<<<<<<<<<<<
 *     cPickle = None
 *     import pickle
 */
    /*except:*/ {
      __Pyx_AddTraceback("zmq.core.socket", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_7);

      /* "zmq/core/socket.pyx":61
 *     pickle = cPickle
 * except:
 *     cPickle = None             # <<<<<<<<<<<<<<
 *     import pickle
 * 
 */
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s__cPickle, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}

      /* "zmq/core/socket.pyx":62
 * except:
 *     cPickle = None
 *     import pickle             # <<<<<<<<<<<<<<
 * 
 * import zmq
 */
      __pyx_t_8 = __Pyx_Import(((PyObject *)__pyx_n_s__pickle), 0, -1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (PyObject_SetAttr(__pyx_m, __pyx_n_s__pickle, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L3_exception_handled;
    }
    __pyx_L4_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L3_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    __pyx_L9_try_end:;
  }

  /* "zmq/core/socket.pyx":64
 *     import pickle
 * 
 * import zmq             # <<<<<<<<<<<<<<
 * from zmq.core import constants
 * from zmq.core.constants import *
 */
  __pyx_t_7 = __Pyx_Import(((PyObject *)__pyx_n_s__zmq), 0, -1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__zmq, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "zmq/core/socket.pyx":65
 * 
 * import zmq
 * from zmq.core import constants             # <<<<<<<<<<<<<<
 * from zmq.core.constants import *
 * from zmq.core.error import ZMQError, ZMQBindError
 */
  __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_7));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__constants));
  PyList_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_n_s__constants));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__constants));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s_44), ((PyObject *)__pyx_t_7), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  __pyx_t_7 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__constants); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__constants, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "zmq/core/socket.pyx":66
 * import zmq
 * from zmq.core import constants
 * from zmq.core.constants import *             # <<<<<<<<<<<<<<
 * from zmq.core.error import ZMQError, ZMQBindError
 * from zmq.utils.strtypes import bytes,unicode,basestring
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s_46));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s_46));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_46));
  __pyx_t_7 = __Pyx_Import(((PyObject *)__pyx_n_s_45), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (__pyx_import_star(__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "zmq/core/socket.pyx":67
 * from zmq.core import constants
 * from zmq.core.constants import *
 * from zmq.core.error import ZMQError, ZMQBindError             # <<<<<<<<<<<<<<
 * from zmq.utils.strtypes import bytes,unicode,basestring
 * 
 */
  __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_7));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__ZMQError));
  PyList_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_n_s__ZMQError));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ZMQError));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__ZMQBindError));
  PyList_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_n_s__ZMQBindError));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ZMQBindError));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s_47), ((PyObject *)__pyx_t_7), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  __pyx_t_7 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ZMQError, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__ZMQBindError); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ZMQBindError, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "zmq/core/socket.pyx":68
 * from zmq.core.constants import *
 * from zmq.core.error import ZMQError, ZMQBindError
 * from zmq.utils.strtypes import bytes,unicode,basestring             # <<<<<<<<<<<<<<
 * 
 * #-----------------------------------------------------------------------------
 */
  __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__bytes));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__bytes));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__bytes));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__unicode));
  PyList_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__unicode));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__unicode));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__basestring));
  PyList_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_n_s__basestring));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__basestring));
  __pyx_t_7 = __Pyx_Import(((PyObject *)__pyx_n_s_48), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__bytes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__bytes, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__unicode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__unicode, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__basestring); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__basestring, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "zmq/core/socket.pyx":99
 *     return False
 * 
 * cdef inline Message _recv_message(void *handle, int flags=0, track=False):             # <<<<<<<<<<<<<<
 *     """Receive a message in a non-copying manner and return a Message."""
 *     cdef int rc
 */
  __pyx_t_7 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_k_1 = __pyx_t_7;
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;

  /* "zmq/core/socket.pyx":227
 * 
 *     @property
 *     def closed(self):             # <<<<<<<<<<<<<<
 *         return _check_closed(self, False)
 * 
 */
  __pyx_t_7 = __Pyx_GetName((PyObject *)__pyx_ptype_3zmq_4core_6socket_Socket, __pyx_n_s__closed); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_3zmq_4core_6socket_Socket->tp_dict, __pyx_n_s__closed, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  PyType_Modified(__pyx_ptype_3zmq_4core_6socket_Socket);

  /* "zmq/core/socket.pyx":559
 *     #-------------------------------------------------------------------------
 * 
 *     cpdef object send(self, object data, int flags=0, copy=True, track=False):             # <<<<<<<<<<<<<<
 *         """s.send(data, flags=0, copy=True, track=False)
 * 
 */
  __pyx_t_7 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_k_18 = __pyx_t_7;
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_k_19 = __pyx_t_7;
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;

  /* "zmq/core/socket.pyx":616
 *             return _send_message(self.handle, msg, flags)
 * 
 *     cpdef object recv(self, int flags=0, copy=True, track=False):             # <<<<<<<<<<<<<<
 *         """s.recv(flags=0, copy=True, track=False)
 * 
 */
  __pyx_t_7 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_k_24 = __pyx_t_7;
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_k_25 = __pyx_t_7;
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;

  /* "zmq/core/socket.pyx":654
 *             return _recv_message(self.handle, flags, track)
 * 
 *     def send_multipart(self, msg_parts, int flags=0, copy=True, track=False, prefix=None):             # <<<<<<<<<<<<<<
 *         """s.send_multipart(msg_parts, flags=0, copy=True, track=False, prefix=None)
 * 
 */
  __pyx_t_7 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_k_26 = __pyx_t_7;
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_k_27 = __pyx_t_7;
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;

  /* "zmq/core/socket.pyx":694
 *         return self.send(msg_parts[-1], flags, copy=copy, track=track)
 * 
 *     def recv_multipart(self, int flags=0, copy=True, track=False):             # <<<<<<<<<<<<<<
 *         """s.recv_multipart(flags=0, copy=True, track=False)
 * 
 */
  __pyx_t_7 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_k_28 = __pyx_t_7;
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_k_29 = __pyx_t_7;
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;

  /* "zmq/core/socket.pyx":728
 *         return parts
 * 
 *     def send_unicode(self, u, int flags=0, copy=False, encoding='utf-8'):             # <<<<<<<<<<<<<<
 *         """s.send_unicode(u, flags=0, copy=False, encoding='utf-8')
 * 
 */
  __pyx_t_7 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_k_30 = __pyx_t_7;
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;

  /* "zmq/core/socket.pyx":876
 * 
 * 
 * __all__ = ['Socket']             # <<<<<<<<<<<<<<
 */
  __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_7));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Socket));
  PyList_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_n_s__Socket));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Socket));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_t_7)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;

  /* "zmq/core/socket.pyx":1
 * """0MQ Socket class."""             # <<<<<<<<<<<<<<
 * 
 * #
 */
  __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_7));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_7)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;

  /* "buffers.pxd":303
 * 
 * 
 * cdef inline object viewfromobject_w(object obj):             # <<<<<<<<<<<<<<
 *     """Wrapper for writable viewfromobject."""
 *     return viewfromobject(obj, 0)
 */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  if (__pyx_m) {
    __Pyx_AddTraceback("init zmq.core.socket", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init zmq.core.socket");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */

#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif /* CYTHON_REFNANNY */

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result) {
        if (dict != __pyx_b) {
            PyErr_Clear();
            result = PyObject_GetAttr(__pyx_b, name);
        }
        if (!result) {
            PyErr_SetObject(PyExc_NameError, name);
        }
    }
    return result;
}

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();

    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;

    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}


#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    /* cause is unused */
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    /* First, check the traceback argument, replacing None with NULL. */
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    /* Next, replace a missing value with None */
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        /* Raising an instance.  The value should be a dummy. */
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        /* Normalize to raise <class>, <instance> */
        Py_DECREF(value);
        value = type;
        #if PY_VERSION_HEX < 0x02050000
            if (PyInstance_Check(type)) {
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
                Py_INCREF(type);
            }
            else {
                type = 0;
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) Py_TYPE(type);
            Py_INCREF(type);
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception class must be a subclass of BaseException");
                goto raise_error;
            }
        #endif
    }

    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

#else /* Python 3+ */

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;

    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (!PyExceptionClass_Check(type)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }

    if (cause) {
        PyObject *fixed_cause;
        if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        }
        else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        }
        else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        if (!value) {
            value = PyObject_CallObject(type, NULL);
        }
        PyException_SetCause(value, fixed_cause);
    }

    PyErr_SetObject(type, value);

    if (tb) {
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
    }

bad:
    return;
}
#endif

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;

    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%s() takes %s %"PY_FORMAT_SIZE_T"d positional argument%s (%"PY_FORMAT_SIZE_T"d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AS_STRING(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;

    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
        } else {
            #if PY_MAJOR_VERSION < 3
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
            #else
            if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
            #endif
                goto invalid_keyword_type;
            } else {
                for (name = first_kw_arg; *name; name++) {
                    #if PY_MAJOR_VERSION >= 3
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                        PyUnicode_Compare(**name, key) == 0) break;
                    #else
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                        _PyString_Eq(**name, key)) break;
                    #endif
                }
                if (*name) {
                    values[name-argnames] = value;
                } else {
                    /* unexpected keyword found */
                    for (name=argnames; name != first_kw_arg; name++) {
                        if (**name == key) goto arg_passed_twice;
                        #if PY_MAJOR_VERSION >= 3
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
                        #else
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
                        #endif
                    }
                    if (kwds2) {
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                    } else {
                        goto invalid_keyword;
                    }
                }
            }
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (Py_TYPE(obj) == type) return 1;
    }
    else {
        if (PyObject_TypeCheck(obj, type)) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%s' has incorrect type (expected %s, got %s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
    if (unlikely(tstate->curexc_type))
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
        goto bad;
    #endif
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
    Py_INCREF(local_type);
    Py_INCREF(local_value);
    Py_INCREF(local_tb);
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    /* Make sure tstate is in a consistent state when we XDECREF
       these objects (XDECREF may run arbitrary code). */
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}


static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is unsubscriptable");
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}


static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}

static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
    PyObject *py_import = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
    if (!py_import)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    #if PY_VERSION_HEX >= 0x02050000
    {
        PyObject *py_level = PyInt_FromLong(level);
        if (!py_level)
            goto bad;
        module = PyObject_CallFunctionObjArgs(py_import,
            name, global_dict, empty_dict, list, py_level, NULL);
        Py_DECREF(py_level);
    }
    #else
    if (level>0) {
        PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
        goto bad;
    }
    module = PyObject_CallFunctionObjArgs(py_import,
        name, global_dict, empty_dict, list, NULL);
    #endif
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(py_import);
    Py_XDECREF(empty_dict);
    return module;
}

static CYTHON_INLINE pyzmq_int64_t __Pyx_PyInt_from_py_pyzmq_int64_t(PyObject* x) {
    const pyzmq_int64_t neg_one = (pyzmq_int64_t)-1, const_zero = (pyzmq_int64_t)0;
    const int is_unsigned = const_zero < neg_one;
    if (sizeof(pyzmq_int64_t) == sizeof(char)) {
        if (is_unsigned)
            return (pyzmq_int64_t)__Pyx_PyInt_AsUnsignedChar(x);
        else
            return (pyzmq_int64_t)__Pyx_PyInt_AsSignedChar(x);
    } else if (sizeof(pyzmq_int64_t) == sizeof(short)) {
        if (is_unsigned)
            return (pyzmq_int64_t)__Pyx_PyInt_AsUnsignedShort(x);
        else
            return (pyzmq_int64_t)__Pyx_PyInt_AsSignedShort(x);
    } else if (sizeof(pyzmq_int64_t) == sizeof(int)) {
        if (is_unsigned)
            return (pyzmq_int64_t)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (pyzmq_int64_t)__Pyx_PyInt_AsSignedInt(x);
    } else if (sizeof(pyzmq_int64_t) == sizeof(long)) {
        if (is_unsigned)
            return (pyzmq_int64_t)__Pyx_PyInt_AsUnsignedLong(x);
        else
            return (pyzmq_int64_t)__Pyx_PyInt_AsSignedLong(x);
    } else if (sizeof(pyzmq_int64_t) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return (pyzmq_int64_t)__Pyx_PyInt_AsUnsignedLongLong(x);
        else
            return (pyzmq_int64_t)__Pyx_PyInt_AsSignedLongLong(x);
    }  else {
        pyzmq_int64_t val;
        PyObject *v = __Pyx_PyNumber_Int(x);
        #if PY_VERSION_HEX < 0x03000000
        if (likely(v) && !PyLong_Check(v)) {
            PyObject *tmp = v;
            v = PyNumber_Long(tmp);
            Py_DECREF(tmp);
        }
        #endif
        if (likely(v)) {
            int one = 1; int is_little = (int)*(unsigned char *)&one;
            unsigned char *bytes = (unsigned char *)&val;
            int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                          bytes, sizeof(val),
                                          is_little, !is_unsigned);
            Py_DECREF(v);
            if (likely(!ret))
                return val;
        }
        return (pyzmq_int64_t)-1;
    }
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_pyzmq_int64_t(pyzmq_int64_t val) {
    const pyzmq_int64_t neg_one = (pyzmq_int64_t)-1, const_zero = (pyzmq_int64_t)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(pyzmq_int64_t) == sizeof(char))  ||
        (sizeof(pyzmq_int64_t) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(pyzmq_int64_t) == sizeof(int)) ||
               (sizeof(pyzmq_int64_t) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(pyzmq_int64_t) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    } else {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&val;
        return _PyLong_FromByteArray(bytes, sizeof(pyzmq_int64_t),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_ZMQ_FD_T(ZMQ_FD_T val) {
    const ZMQ_FD_T neg_one = (ZMQ_FD_T)-1, const_zero = (ZMQ_FD_T)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(ZMQ_FD_T) == sizeof(char))  ||
        (sizeof(ZMQ_FD_T) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(ZMQ_FD_T) == sizeof(int)) ||
               (sizeof(ZMQ_FD_T) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(ZMQ_FD_T) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    } else {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&val;
        return _PyLong_FromByteArray(bytes, sizeof(ZMQ_FD_T),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = PyObject_GetAttr(o, n);
    if (!r) {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError))
            goto bad;
        PyErr_Clear();
        r = d;
        Py_INCREF(d);
    }
    return r;
bad:
    return NULL;
}

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
    if (s1 == s2) {   /* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        if (PyBytes_GET_SIZE(s1) != PyBytes_GET_SIZE(s2)) {
            return (equals == Py_NE);
        } else if (PyBytes_GET_SIZE(s1) == 1) {
            if (equals == Py_EQ)
                return (PyBytes_AS_STRING(s1)[0] == PyBytes_AS_STRING(s2)[0]);
            else
                return (PyBytes_AS_STRING(s1)[0] != PyBytes_AS_STRING(s2)[0]);
        } else {
            int result = memcmp(PyBytes_AS_STRING(s1), PyBytes_AS_STRING(s2), (size_t)PyBytes_GET_SIZE(s1));
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
}

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
    if (s1 == s2) {   /* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */
        return (equals == Py_EQ);
    } else if (PyUnicode_CheckExact(s1) & PyUnicode_CheckExact(s2)) {
        if (PyUnicode_GET_SIZE(s1) != PyUnicode_GET_SIZE(s2)) {
            return (equals == Py_NE);
        } else if (PyUnicode_GET_SIZE(s1) == 1) {
            if (equals == Py_EQ)
                return (PyUnicode_AS_UNICODE(s1)[0] == PyUnicode_AS_UNICODE(s2)[0]);
            else
                return (PyUnicode_AS_UNICODE(s1)[0] != PyUnicode_AS_UNICODE(s2)[0]);
        } else {
            int result = PyUnicode_Compare(s1, s2);
            if ((result == -1) && unlikely(PyErr_Occurred()))
                return -1;
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyUnicode_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyUnicode_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
}

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned char" :
                    "value too large to convert to unsigned char");
            }
            return (unsigned char)-1;
        }
        return (unsigned char)val;
    }
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned short" :
                    "value too large to convert to unsigned short");
            }
            return (unsigned short)-1;
        }
        return (unsigned short)val;
    }
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned int" :
                    "value too large to convert to unsigned int");
            }
            return (unsigned int)-1;
        }
        return (unsigned int)val;
    }
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
    const char neg_one = (char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to char" :
                    "value too large to convert to char");
            }
            return (char)-1;
        }
        return (char)val;
    }
    return (char)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
    const short neg_one = (short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to short" :
                    "value too large to convert to short");
            }
            return (short)-1;
        }
        return (short)val;
    }
    return (short)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
    const signed char neg_one = (signed char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed char" :
                    "value too large to convert to signed char");
            }
            return (signed char)-1;
        }
        return (signed char)val;
    }
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
    const signed short neg_one = (signed short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed short" :
                    "value too large to convert to signed short");
            }
            return (signed short)-1;
        }
        return (signed short)val;
    }
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
    const signed int neg_one = (signed int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed int" :
                    "value too large to convert to signed int");
            }
            return (signed int)-1;
        }
        return (signed int)val;
    }
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return (unsigned long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned long");
                return (unsigned long)-1;
            }
            return (unsigned long)PyLong_AsUnsignedLong(x);
        } else {
            return (unsigned long)PyLong_AsLong(x);
        }
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned PY_LONG_LONG");
            return (unsigned PY_LONG_LONG)-1;
        }
        return (unsigned PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned PY_LONG_LONG");
                return (unsigned PY_LONG_LONG)-1;
            }
            return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
    const long neg_one = (long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to long");
            return (long)-1;
        }
        return (long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long)-1;
            }
            return (long)PyLong_AsUnsignedLong(x);
        } else {
            return (long)PyLong_AsLong(x);
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long)-1;
        val = __Pyx_PyInt_AsLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to PY_LONG_LONG");
            return (PY_LONG_LONG)-1;
        }
        return (PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to PY_LONG_LONG");
                return (PY_LONG_LONG)-1;
            }
            return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
    const signed long neg_one = (signed long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed long");
            return (signed long)-1;
        }
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return (signed long)PyLong_AsUnsignedLong(x);
        } else {
            return (signed long)PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed PY_LONG_LONG");
            return (signed PY_LONG_LONG)-1;
        }
        return (signed PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed PY_LONG_LONG");
                return (signed PY_LONG_LONG)-1;
            }
            return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (signed PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        signed PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE int __Pyx_StrEq(const char *s1, const char *s2) {
     while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
     return *s1 == *s2;
}

static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        #if PY_VERSION_HEX < 0x02050000
        return PyErr_Warn(NULL, message);
        #else
        return PyErr_WarnEx(NULL, message, 1);
        #endif
    }
    return 0;
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];

    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(class_name);
    #else
    py_name = PyUnicode_FromString(class_name);
    #endif
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%s.%s is not a type object",
            module_name, class_name);
        goto bad;
    }
    if (!strict && ((PyTypeObject *)result)->tp_basicsize > (Py_ssize_t)size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        #if PY_VERSION_HEX < 0x02050000
        if (PyErr_Warn(NULL, warning) < 0) goto bad;
        #else
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
        #endif
    }
    else if (((PyTypeObject *)result)->tp_basicsize != (Py_ssize_t)size) {
        PyErr_Format(PyExc_ValueError,
            "%s.%s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;

    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(name);
    #else
    py_name = PyUnicode_FromString(name);
    #endif
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyMapping_GetItemString(dict, (char *)"__pyx_vtable__");
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;

    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%s does not export expected C function %s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %s.%s has wrong signature (expected %s, got %s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %s.%s has wrong signature (expected %s, got %s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno,
                               int __pyx_lineno, const char *__pyx_filename) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;

    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(__pyx_filename);
    #else
    py_srcfile = PyUnicode_FromString(__pyx_filename);
    #endif
    if (!py_srcfile) goto bad;
    if (__pyx_clineno) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        #if PY_MAJOR_VERSION >= 3
        0,            /*int kwonlyargcount,*/
        #endif
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple,  /*PyObject *consts,*/
        __pyx_empty_tuple,  /*PyObject *names,*/
        __pyx_empty_tuple,  /*PyObject *varnames,*/
        __pyx_empty_tuple,  /*PyObject *freevars,*/
        __pyx_empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    if (!py_code) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

/* Type Conversion Functions */

static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}

static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_VERSION_HEX < 0x03000000
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_VERSION_HEX < 0x03000000
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_VERSION_HEX < 0x03000000
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%s__ returned non-%s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}

static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}

static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
       return (size_t)-1;
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       PyErr_SetString(PyExc_OverflowError,
                       "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
