Commit 17800ac8 authored by malosek's avatar malosek

setsockopt cleanup in pyzmq.cpp

parent 7a5db604
...@@ -140,14 +140,29 @@ PyObject *socket_setsockopt (socket_t *self, PyObject *args, PyObject *kwdict) ...@@ -140,14 +140,29 @@ PyObject *socket_setsockopt (socket_t *self, PyObject *args, PyObject *kwdict)
} }
int rc; int rc;
if (PyInt_Check (optval)) {
int val = PyInt_AsLong (optval); switch (option) {
rc = zmq_setsockopt (self->handle, option, &val, sizeof (int)); case ZMQ_HWM:
} case ZMQ_LWM:
if (PyString_Check (optval)) case ZMQ_SWAP:
rc = zmq_setsockopt (self->handle, option, PyString_AsString (optval), case ZMQ_AFFINITY:
PyString_Size (optval)); case ZMQ_RATE:
else { 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; rc = -1;
errno = EINVAL; errno = EINVAL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment