[zeromq-dev] zmq_setsockopt() returning invalid argument
Min
miniway at gmail.com
Sun Feb 17 05:33:19 CET 2013
Hi
You need to set socket options before connect.
Thanks
Min
2013년 2월 17일 일요일에 suraj nellikar님이 작성:
> Hi,
> I am using zmq 3.2 library on Ubuntu (32 bit machine). I am trying to run
> a test PUB-SUB model but the client is failing to set the sockopt to
> ZMQ_SUBSCRIBE. Any idea what am I doing wrong here?
>
> Here's the snippet of the code.
> main() {
> void *context = zmq_ctx_new();
> void *req = zmq_socket(context,ZMQ_REQ);
> void *sub = zmq_socket(context,ZMQ_SUBSCRIBE);
>
> int rc = zmq_connect(req,"tcp://127.0.0.1:5555");
> printf("req connect, rc = %d\n",rc);
> rc = zmq_connect(sub,"tcp://192.168.72.130:6666");
> printf("sub connect, rc = %d\n",rc);
> uint64_t affinity = 1;
> rc = zmq_setsockopt (sub, ZMQ_AFFINITY, &affinity, sizeof affinity);
> //This works only when I use uint64_t for affinity. It fails for int.
> printf("setsockopt, rc = %d, errno = %s\n",rc,strerror(errno));
> rc = zmq_setsockopt(sub,ZMQ_SUBSCRIBE,"",0);
> //This always fails! rc is always -1
> printf("setsockopt, ZMQ_SUBSCRIBE = %d,rc = %d, errno =
> %s\n",ZMQ_SUBSCRIBE,rc,strerror(errno));
>
> Thanks.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130217/72371b8e/attachment.htm>
More information about the zeromq-dev
mailing list