Skip to content

Commit

Permalink
update deprecated zmq functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanhhughes committed Dec 12, 2024
1 parent 4c3414a commit 338ff0f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/zmq_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,30 @@ struct ZmqReceiver::Detail {
Detail(const std::string& url, size_t, bool conflate) {
socket.reset(new zmq::socket_t(ZmqContextHolder::instance().context(), ZMQ_SUB));
socket->connect(url);
#if ZMQ_VERSION < ZMQ_MAKE_VERSION(4, 7, 0)
socket->setsockopt(ZMQ_SUBSCRIBE, "", 0);
#else
socket->set(zmq::sockopt::subscribe, "", 0);
#endif

if (conflate) {
int conflate_flag = 1;
#if ZMQ_VERSION < ZMQ_MAKE_VERSION(4, 7, 0)
socket->setsockopt(ZMQ_CONFLATE, &conflate_flag, sizeof(conflate_flag));
#else
socket->set(zmq::sockopt::conflate, &conflate_flag, sizeof(conflate_flag));
#endif
}
}

~Detail() = default;

bool recv(size_t timeout_ms) {
#if ZMQ_VERSION < ZMQ_MAKE_VERSION(4, 7, 1)
if (!socket->connected()) {
#else
if (!socket) {
#endif
return false;
}

Expand Down

0 comments on commit 338ff0f

Please sign in to comment.