diff --git a/CHANELOG.md b/CHANELOG.md index 2332d69d..260da376 100644 --- a/CHANELOG.md +++ b/CHANELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.82.0 (2025-04-23) + +- Initialize sockets in ZMQPulisher and add host name argument. + ## 0.81.1 (2025-04-14) - Use only ZMQ for BinPickingTask when compiled with ZMQ. diff --git a/CMakeLists.txt b/CMakeLists.txt index e116ab0f..116dc668 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,8 @@ set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE ) # Define here the needed parameters # make sure to change the version in docs/Makefile set (MUJINCLIENT_VERSION_MAJOR 0) -set (MUJINCLIENT_VERSION_MINOR 81) -set (MUJINCLIENT_VERSION_PATCH 1) +set (MUJINCLIENT_VERSION_MINOR 82) +set (MUJINCLIENT_VERSION_PATCH 0) set (MUJINCLIENT_VERSION ${MUJINCLIENT_VERSION_MAJOR}.${MUJINCLIENT_VERSION_MINOR}.${MUJINCLIENT_VERSION_PATCH}) set (MUJINCLIENT_SOVERSION ${MUJINCLIENT_VERSION_MAJOR}.${MUJINCLIENT_VERSION_MINOR}) set (CLIENT_SOVERSION ${MUJINCLIENT_VERSION_MAJOR}.${MUJINCLIENT_VERSION_MINOR}) diff --git a/include/mujincontrollerclient/mujinzmq.h b/include/mujincontrollerclient/mujinzmq.h index 07d59a82..3d0cae4c 100644 --- a/include/mujincontrollerclient/mujinzmq.h +++ b/include/mujincontrollerclient/mujinzmq.h @@ -52,7 +52,7 @@ class MUJINCLIENT_API ZmqSubscriber class MUJINCLIENT_API ZmqPublisher { public: - ZmqPublisher(const unsigned int port); + ZmqPublisher(const unsigned int port, const std::string& host = std::string()); virtual ~ZmqPublisher(); bool Publish(const std::string& messagestr); @@ -62,7 +62,7 @@ class MUJINCLIENT_API ZmqPublisher } protected: - void _InitializeSocket(boost::shared_ptr context); + void _InitializeSocket(boost::shared_ptr context, const std::string& host); void _DestroySocket(); boost::shared_ptr _context; diff --git a/src/mujinzmq.cpp b/src/mujinzmq.cpp index fcfb814e..61ddc618 100644 --- a/src/mujinzmq.cpp +++ b/src/mujinzmq.cpp @@ -175,9 +175,10 @@ void ZmqSubscriber::_DestroySocket() } } -ZmqPublisher::ZmqPublisher(const unsigned int port) +ZmqPublisher::ZmqPublisher(const unsigned int port, const std::string& host) { _port = port; + _InitializeSocket(nullptr, host); } ZmqPublisher::~ZmqPublisher() @@ -192,7 +193,7 @@ bool ZmqPublisher::Publish(const std::string& messagestr) return _socket->send(message); } -void ZmqPublisher::_InitializeSocket(boost::shared_ptr context) +void ZmqPublisher::_InitializeSocket(boost::shared_ptr context, const std::string& host) { if (!!context) { _context = context; @@ -211,7 +212,7 @@ void ZmqPublisher::_InitializeSocket(boost::shared_ptr context) _socket->setsockopt(ZMQ_LINGER, 100); // ms std::ostringstream port_stream; port_stream << _port; - _socket->bind (("tcp://*:" + port_stream.str()).c_str()); + _socket->bind (("tcp://" + (host.empty() ? "*" : host) + ":" + port_stream.str()).c_str()); } void ZmqPublisher::_DestroySocket()