summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authormalosek <malosek@fastmq.com>2009-09-16 14:25:49 +0200
committermalosek <malosek@fastmq.com>2009-09-16 14:25:49 +0200
commit17800ac85e667d18124d0e90f9387d6c90887570 (patch)
treeaa6e7aad626fdf731e9081268457855eedd08ab4 /python
parent7a5db6041f4f11ed502fa7446da900509dedb00f (diff)
setsockopt cleanup in pyzmq.cpp
Diffstat (limited to 'python')
-rw-r--r--python/pyzmq.cpp31
1 files changed, 23 insertions, 8 deletions
diff --git a/python/pyzmq.cpp b/python/pyzmq.cpp
index c550eb5..47478e0 100644
--- a/python/pyzmq.cpp
+++ b/python/pyzmq.cpp
@@ -140,14 +140,29 @@ PyObject *socket_setsockopt (socket_t *self, PyObject *args, PyObject *kwdict)
}
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 {
+
+ 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;
}