zeromq / cppzmq

Header-only C++ binding for libzmq
http://www.zeromq.org
MIT License
1.93k stars 757 forks source link

How to correctly set receive timeout #562

Closed andrewdavidmackenzie closed 2 years ago

andrewdavidmackenzie commented 2 years ago

I am trying to fix a deprecation warning in code using cpzmq, related to setting socket opts and context ops. I am not an experienced cpp programmer and unfamiliar with a lot of this :-(

I couldn't find docs or a code sample on how to set the received timeout

code was

  int timeout = 10000;
  response_puller.setsockopt(ZMQ_RCVTIMEO, &timeout, sizeof(timeout));

and now I am trying

  response_puller.set(zmq::sockopt::rcvtimeo, &timeout);

without much luck. All help appreciated.

gummif commented 2 years ago

What about response_puller.set(zmq::sockopt::rcvtimeo, timeout); ?

andrewdavidmackenzie commented 2 years ago

That worked. Looks like the error message was confusing me and I didn't realize it was so obvious.

Sorry for the noise and thanks!