diff options
author | Martin Sustrik <sustrik@fastmq.com> | 2009-09-16 15:27:39 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@fastmq.com> | 2009-09-16 15:27:39 +0200 |
commit | fc7715b4636be7a0d49f27234359ddfddce23f5b (patch) | |
tree | bd63ddd7b86e591935b871de40ba1e341300a6a0 /python | |
parent | f1c72d693e3bd252866a1f78e575493573eb57fe (diff) | |
parent | c6665f46be7eb701866441087c35cdb1a08fc641 (diff) |
Merge branch 'master' of git@github.com:sustrik/zeromq2
Diffstat (limited to 'python')
-rw-r--r-- | python/pyzmq.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/python/pyzmq.cpp b/python/pyzmq.cpp index c550eb5..628d037 100644 --- a/python/pyzmq.cpp +++ b/python/pyzmq.cpp @@ -139,15 +139,30 @@ PyObject *socket_setsockopt (socket_t *self, PyObject *args, PyObject *kwdict) return NULL; } - int rc; - if (PyInt_Check (optval)) { - int val = PyInt_AsLong (optval); - rc = zmq_setsockopt (self->handle, option, &val, sizeof (int)); - } - if (PyString_Check (optval)) - rc = zmq_setsockopt (self->handle, option, PyString_AsString (optval), - PyString_Size (optval)); - else { + int rc = 0; + + switch (option) { + case ZMQ_HWM: + case ZMQ_LWM: + case ZMQ_SWAP: + case ZMQ_AFFINITY: + case ZMQ_RATE: + case ZMQ_RECOVERY_IVL: + case ZMQ_MCAST_LOOP: + { + int val = PyInt_AsLong (optval); + rc = zmq_setsockopt (self->handle, option, &val, sizeof (int)); + break; + } + case ZMQ_IDENTITY: + case ZMQ_SUBSCRIBE: + case ZMQ_UNSUBSCRIBE: + + rc = zmq_setsockopt (self->handle, option, PyString_AsString (optval), + PyString_Size (optval)); + break; + + default: rc = -1; errno = EINVAL; } |