diff --git a/mediachanger/AcsProxyZmq.cpp b/mediachanger/AcsProxyZmq.cpp index cc398f29a175301857e1677768de517862e4f067..47788811e2893087a8c0adfa92305a5b30e57a0c 100644 --- a/mediachanger/AcsProxyZmq.cpp +++ b/mediachanger/AcsProxyZmq.cpp @@ -288,9 +288,9 @@ void AcsProxyZmq::forceDismountTape(const std::string &vid, const LibrarySlot &l //------------------------------------------------------------------------------ // serverSocketInstance //------------------------------------------------------------------------------ -ZmqSocketMT &AcsProxyZmq::serverSocketInstance() { +ZmqSocket &AcsProxyZmq::serverSocketInstance() { if(nullptr == m_serverSocket) { - m_serverSocket.reset(new ZmqSocketMT(m_zmqContext, ZMQ_REQ)); + m_serverSocket.reset(new ZmqSocket(m_zmqContext, ZMQ_REQ)); connectZmqSocketToLocalhost(*m_serverSocket, m_serverPort); } return *m_serverSocket; diff --git a/mediachanger/AcsProxyZmq.hpp b/mediachanger/AcsProxyZmq.hpp index d0c24e8a6348271dc6051943f265ffc59cfd656b..3ac7ddcfab29770ea0fda6b67fc2c112bbcf2cd2 100644 --- a/mediachanger/AcsProxyZmq.hpp +++ b/mediachanger/AcsProxyZmq.hpp @@ -20,7 +20,7 @@ #include "mediachanger/Constants.hpp" #include "mediachanger/MediaChangerProxy.hpp" -#include "mediachanger/ZmqSocketMT.hpp" +#include "mediachanger/ZmqSocket.hpp" #include <memory> #include <mutex> @@ -102,7 +102,7 @@ private: /** * Socket connecting this proxy to the daemon it represents. */ - std::unique_ptr<ZmqSocketMT> m_serverSocket; + std::unique_ptr<ZmqSocket> m_serverSocket; /** * Returns the socket instance connecting this proxy to the daemon it @@ -114,7 +114,7 @@ private: * * @return The socket connecting this proxy the daemon it represents. */ - ZmqSocketMT &serverSocketInstance(); + ZmqSocket &serverSocketInstance(); }; // class AcsProxyZmq diff --git a/mediachanger/CMakeLists.txt b/mediachanger/CMakeLists.txt index ef15b0556c8c4b838bafc17cef376c0d83684c06..89d8bd6d0cab04a9ccbbc4a49a2b18931e2a37a0 100644 --- a/mediachanger/CMakeLists.txt +++ b/mediachanger/CMakeLists.txt @@ -51,9 +51,7 @@ set (MEDIACHANGER_LIB_SRC_FILES TapeLibraryType.cpp ZmqContextSingleton.cpp ZmqMsg.cpp - ZmqSocket.cpp - ZmqSocketMT.cpp - ZmqSocketST.cpp) + ZmqSocket.cpp) add_library (ctamediachanger SHARED ${MEDIACHANGER_LIB_SRC_FILES}) diff --git a/mediachanger/ZmqSocket.cpp b/mediachanger/ZmqSocket.cpp index da312b682230740becd135768d1e38ee0baa0374..06f61c51b95c47864c68ad355b2512a5ac3224e7 100644 --- a/mediachanger/ZmqSocket.cpp +++ b/mediachanger/ZmqSocket.cpp @@ -16,16 +16,122 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "mediachanger/messages.hpp" #include "mediachanger/ZmqSocket.hpp" +#include "common/exception/Exception.hpp" + +namespace cta { +namespace mediachanger { //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -cta::mediachanger::ZmqSocket::ZmqSocket() { +ZmqSocket::ZmqSocket(void *const zmqContext, const int socketType) { + m_zmqSocket = zmq_socket (zmqContext, socketType); + if (NULL == m_zmqSocket) { + const int savedErrno = errno; + cta::exception::Exception ex; + ex.getMessage() << "zmq_socket() failed: " << zmqErrnoToStr(savedErrno); + throw ex; + } } - + //------------------------------------------------------------------------------ // destructor //------------------------------------------------------------------------------ -cta::mediachanger::ZmqSocket::~ZmqSocket() throw() { +ZmqSocket::~ZmqSocket() throw() { + try { + close(); + } catch(...) { + // Ignore any exceptions because this is a destructor. + } +} + +//------------------------------------------------------------------------------ +// close +//------------------------------------------------------------------------------ +void ZmqSocket::close() { + if(m_zmqSocket == NULL) { + return; + } + + if(zmq_close(m_zmqSocket)) { + const int savedErrno = errno; + cta::exception::Exception ex; + ex.getMessage() << "zmq_close() failed: " << zmqErrnoToStr(savedErrno); + throw ex; + } + m_zmqSocket = NULL; +} + +//------------------------------------------------------------------------------ +// bind +//------------------------------------------------------------------------------ +void ZmqSocket::bind (const std::string &endpoint) { + if(zmq_bind(m_zmqSocket, endpoint.c_str())) { + const int savedErrno = errno; + cta::exception::Exception ex; + ex.getMessage() << "zmq_bind failed(): " << zmqErrnoToStr(savedErrno); + throw ex; + } +} + +//------------------------------------------------------------------------------ +// connect +//------------------------------------------------------------------------------ +void ZmqSocket::connect(const std::string &endpoint) { + if(zmq_connect(m_zmqSocket, endpoint.c_str())) { + const int savedErrno = errno; + cta::exception::Exception ex; + ex.getMessage() << "zmq_connect() failed: " << zmqErrnoToStr(savedErrno); + throw ex; + } +} + +//------------------------------------------------------------------------------ +// send +//------------------------------------------------------------------------------ +void ZmqSocket::send(ZmqMsg &msg, const int flags) { + send(&msg.getZmqMsg(), flags); } + +//------------------------------------------------------------------------------ +// send +//------------------------------------------------------------------------------ +void ZmqSocket::send(zmq_msg_t *const msg, const int flags) { + if(-1 == zmq_msg_send(msg, m_zmqSocket, flags)) { + const int savedErrno = errno; + cta::exception::Exception ex; + ex.getMessage() << "zmq_msg_send() failed: " << zmqErrnoToStr(savedErrno); + throw ex; + } +} + +//------------------------------------------------------------------------------ +// recv +//------------------------------------------------------------------------------ +void ZmqSocket::recv(ZmqMsg &msg, const int flags) { + recv(&msg.getZmqMsg(), flags); +} + +//------------------------------------------------------------------------------ +// recv +//------------------------------------------------------------------------------ +void ZmqSocket::recv(zmq_msg_t *const msg, int flags) { + if(-1 == zmq_msg_recv (msg, m_zmqSocket, flags)) { + const int savedErrno = errno; + cta::exception::Exception ex; + ex.getMessage() << "zmq_msg_recv() failed: " << zmqErrnoToStr(savedErrno); + throw ex; + } +} + +//------------------------------------------------------------------------------ +// getZmqSocket +//------------------------------------------------------------------------------ +void *ZmqSocket::getZmqSocket() const throw() { + return m_zmqSocket; +} + +} // namespace mediachanger +} // namespace cta diff --git a/mediachanger/ZmqSocket.hpp b/mediachanger/ZmqSocket.hpp index 424913dfa9e3b7a1b13fbf6dbf183e9173fe9694..fc7c755240c579a1ead9cbcc12afa6fd4c0cee8a 100644 --- a/mediachanger/ZmqSocket.hpp +++ b/mediachanger/ZmqSocket.hpp @@ -20,46 +20,66 @@ #include "mediachanger/ZmqMsg.hpp" -#include <string> -#include <zmq.h> - namespace cta { namespace mediachanger { /** - * Abstract C++ class that defines the interace of a wrapper around a ZMQ - * socket. + * A C++ wrapper around a ZMQ socket. */ class ZmqSocket { public: + /** * Constructor. + * + * @param zmqContext The ZMQ context. + * @param socketType The type of the ZMQ socket. + */ + ZmqSocket(void *const zmqContext, const int socketType); + + /** + * Delete copy constructor. + */ + ZmqSocket(const ZmqSocket&) = delete; + + /** + * Delete move constructor. */ - ZmqSocket(); + ZmqSocket(ZmqSocket&&) = delete; + /** + * Delete copy assignment operator. + */ + ZmqSocket &operator=(const ZmqSocket &) = delete; + + /** + * Delete move assignment operator. + */ + ZmqSocket &operator=(ZmqSocket &&) = delete; + /** * Destructor. */ - virtual ~ZmqSocket() throw() = 0; + ~ZmqSocket() throw(); /** * Closes the ZMQ socket. */ - virtual void close() = 0; + void close(); /** * Binds the ZMQ socket to the specified endpoint. * * @param endpoint The endpoint to bind to. */ - virtual void bind(const std::string &endpoint) = 0; + void bind(const std::string &endpoint); /** * Connects the socket to the spedicied endpoint. * * @param endpoint The endpoint to connect to. */ - virtual void connect(const std::string &endpoint) = 0; + void connect(const std::string &endpoint); /** * Sends the specified ZMQ message over the socket. @@ -67,7 +87,7 @@ public: * @param msg The ZMQ messge to be sent. * @param flags See manual page of zmq_msg_send(). */ - virtual void send(ZmqMsg &msg, const int flags = 0) = 0; + void send(ZmqMsg &msg, const int flags = 0); /** * Sends the specified ZMQ message over the socket. @@ -75,7 +95,7 @@ public: * @param msg The ZMQ messge to be sent. * @param flags See manual page of zmq_msg_send(). */ - virtual void send(zmq_msg_t *const msg, const int flags = 0) = 0; + void send(zmq_msg_t *const msg, const int flags = 0); /** * Receives a ZMQ mesage from the socket. @@ -83,7 +103,7 @@ public: * @param msg Output parameter: The received ZMQ messge. * @param flags See manual page of zmq_msg_send(). */ - virtual void recv(ZmqMsg &msg, const int flags = 0) = 0; + void recv(ZmqMsg &msg, const int flags = 0); /** * Receives a ZMQ mesage from the socket. @@ -91,26 +111,21 @@ public: * @param msg Output parameter: The received ZMQ messge. * @param flags See manual page of zmq_msg_send(). */ - virtual void recv(zmq_msg_t *const msg, const int flags = 0) = 0; + void recv(zmq_msg_t *const msg, const int flags = 0); /** * Returns the ZMQ socket wrappeed by this class. * * @return The ZMQ socket wrappeed by this class. */ - virtual void *getZmqSocket() const throw() = 0; + void *getZmqSocket() const throw(); private: /** - * Copy constructor made private to prevent copies. - */ - ZmqSocket(const ZmqSocket&); - - /** - * Assignment operator made private to prevent assignments. + * The ZMQ socket. */ - void operator=(const ZmqSocket &); + void *m_zmqSocket; }; // class ZmqSocket diff --git a/mediachanger/ZmqSocketMT.cpp b/mediachanger/ZmqSocketMT.cpp deleted file mode 100644 index 50a87b962787b248a1f044492e5228c8a50f76bc..0000000000000000000000000000000000000000 --- a/mediachanger/ZmqSocketMT.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * The CERN Tape Archive(CTA) project - * Copyright(C) 2015 CERN - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - *(at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "mediachanger/ZmqSocketMT.hpp" -#include "common/exception/Exception.hpp" - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -cta::mediachanger::ZmqSocketMT::ZmqSocketMT(void *const zmqContext, - const int socketType): m_socket(zmqContext, socketType) { -} - -//------------------------------------------------------------------------------ -// destructor -//------------------------------------------------------------------------------ -cta::mediachanger::ZmqSocketMT::~ZmqSocketMT() throw() { - try { - close(); - } catch(...) { - // Ignore any exceptions because this is a destructor. - } -} - -//------------------------------------------------------------------------------ -// close -//------------------------------------------------------------------------------ -void cta::mediachanger::ZmqSocketMT::close() { - std::lock_guard<std::mutex> lock(m_mutex); - m_socket.close(); -} - -//------------------------------------------------------------------------------ -// bind -//------------------------------------------------------------------------------ -void cta::mediachanger::ZmqSocketMT::bind (const std::string &endpoint) { - std::lock_guard<std::mutex> lock(m_mutex); - m_socket.bind(endpoint); -} - -//------------------------------------------------------------------------------ -// connect -//------------------------------------------------------------------------------ -void cta::mediachanger::ZmqSocketMT::connect(const std::string &endpoint) { - std::lock_guard<std::mutex> lock(m_mutex); - m_socket.connect(endpoint); -} - -//------------------------------------------------------------------------------ -// send -//------------------------------------------------------------------------------ -void cta::mediachanger::ZmqSocketMT::send(ZmqMsg &msg, const int flags) { - std::lock_guard<std::mutex> lock(m_mutex); - m_socket.send(msg, flags); -} - -//------------------------------------------------------------------------------ -// send -//------------------------------------------------------------------------------ -void cta::mediachanger::ZmqSocketMT::send(zmq_msg_t *const msg, - const int flags) { - std::lock_guard<std::mutex> lock(m_mutex); - m_socket.send(msg, flags); -} - -//------------------------------------------------------------------------------ -// recv -//------------------------------------------------------------------------------ -void cta::mediachanger::ZmqSocketMT::recv(ZmqMsg &msg, const int flags) { - std::lock_guard<std::mutex> lock(m_mutex); - m_socket.recv(msg, flags); -} - -//------------------------------------------------------------------------------ -// recv -//------------------------------------------------------------------------------ -void cta::mediachanger::ZmqSocketMT::recv(zmq_msg_t *const msg, int flags) { - std::lock_guard<std::mutex> lock(m_mutex); - m_socket.recv(msg, flags); -} - -//------------------------------------------------------------------------------ -// getZmqSocket -//------------------------------------------------------------------------------ -void *cta::mediachanger::ZmqSocketMT::getZmqSocket() const throw() { - return m_socket.getZmqSocket(); -} diff --git a/mediachanger/ZmqSocketMT.hpp b/mediachanger/ZmqSocketMT.hpp deleted file mode 100644 index d9040a41e56c125ce305443da49d87e0642a1c70..0000000000000000000000000000000000000000 --- a/mediachanger/ZmqSocketMT.hpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * The CERN Tape Archive(CTA) project - * Copyright(C) 2015 CERN - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - *(at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include "mediachanger/ZmqSocket.hpp" -#include "mediachanger/ZmqSocketST.hpp" - -#include <mutex> -#include <pthread.h> -#include <string> -#include <zmq.h> - -namespace cta { -namespace mediachanger { - -/** - * A "Multi-Threaded" ZMQ socket. - * - * This concrete C++ class wraps a ZMQ socket and provides a thread safe - * interface by acting as a monitor. If a single-threaded use is required then - * the ZmqSocketST class should be used instead. - * - * Please note that the getZmqSocket() method is not thread safe. - */ -class ZmqSocketMT: public ZmqSocket { -public: - - /** - * Constructor. - * - * @param zmqContext The ZMQ context. - * @param socketType The type of the ZMQ socket. - */ - ZmqSocketMT(void *const zmqContext, const int socketType); - - /** - * Destructor. - */ - ~ZmqSocketMT() throw(); - - /** - * Closes the ZMQ socket. - */ - void close(); - - /** - * Binds the ZMQ socket to the specified endpoint. - * - * @param endpoint The endpoint to bind to. - */ - void bind(const std::string &endpoint); - - /** - * Connects the socket to the spedicied endpoint. - * - * @param endpoint The endpoint to connect to. - */ - void connect(const std::string &endpoint); - - /** - * Sends the specified ZMQ message over the socket. - * - * @param msg The ZMQ messge to be sent. - * @param flags See manual page of zmq_msg_send(). - */ - void send(ZmqMsg &msg, const int flags = 0); - - /** - * Sends the specified ZMQ message over the socket. - * - * @param msg The ZMQ messge to be sent. - * @param flags See manual page of zmq_msg_send(). - */ - void send(zmq_msg_t *const msg, const int flags = 0); - - /** - * Receives a ZMQ mesage from the socket. - * - * @param msg Output parameter: The received ZMQ messge. - * @param flags See manual page of zmq_msg_send(). - */ - void recv(ZmqMsg &msg, const int flags = 0); - - /** - * Receives a ZMQ mesage from the socket. - * - * @param msg Output parameter: The received ZMQ messge. - * @param flags See manual page of zmq_msg_send(). - */ - void recv(zmq_msg_t *const msg, const int flags = 0); - - /** - * Returns the ZMQ socket wrappeed by this class. - * - * Please note that the getZmqSocket() method is not thread safe. - * - * @return The ZMQ socket wrappeed by this class. - */ - void *getZmqSocket() const throw(); - -private: - - /** - * Mutex used to implement a critical section around the enclosed - * ZMQ socket. - */ - std::mutex m_mutex; - - /** - * The non thread-safe socket to be protected. - */ - ZmqSocketST m_socket; - -}; // class ZmqSocketMT - -} // namespace mediachanger -} // namespace cta diff --git a/mediachanger/ZmqSocketST.cpp b/mediachanger/ZmqSocketST.cpp deleted file mode 100644 index e0f20ad3c951828c831c796ce00775c5ab05bcbb..0000000000000000000000000000000000000000 --- a/mediachanger/ZmqSocketST.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * The CERN Tape Archive(CTA) project - * Copyright(C) 2015 CERN - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - *(at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "mediachanger/messages.hpp" -#include "mediachanger/ZmqSocketST.hpp" -#include "common/exception/Exception.hpp" - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -cta::mediachanger::ZmqSocketST::ZmqSocketST(void *const zmqContext, - const int socketType) { - m_zmqSocket = zmq_socket (zmqContext, socketType); - if (NULL == m_zmqSocket) { - const int savedErrno = errno; - cta::exception::Exception ex; - ex.getMessage() << "zmq_socket() failed: " << zmqErrnoToStr(savedErrno); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// destructor -//------------------------------------------------------------------------------ -cta::mediachanger::ZmqSocketST::~ZmqSocketST() throw() { - try { - close(); - } catch(...) { - // Ignore any exceptions because this is a destructor. - } -} - -//------------------------------------------------------------------------------ -// close -//------------------------------------------------------------------------------ -void cta::mediachanger::ZmqSocketST::close() { - if(m_zmqSocket == NULL) { - return; - } - - if(zmq_close(m_zmqSocket)) { - const int savedErrno = errno; - cta::exception::Exception ex; - ex.getMessage() << "zmq_close() failed: " << zmqErrnoToStr(savedErrno); - throw ex; - } - m_zmqSocket = NULL; -} - -//------------------------------------------------------------------------------ -// bind -//------------------------------------------------------------------------------ -void cta::mediachanger::ZmqSocketST::bind (const std::string &endpoint) { - if(zmq_bind(m_zmqSocket, endpoint.c_str())) { - const int savedErrno = errno; - cta::exception::Exception ex; - ex.getMessage() << "zmq_bind failed(): " << zmqErrnoToStr(savedErrno); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// connect -//------------------------------------------------------------------------------ -void cta::mediachanger::ZmqSocketST::connect(const std::string &endpoint) { - if(zmq_connect(m_zmqSocket, endpoint.c_str())) { - const int savedErrno = errno; - cta::exception::Exception ex; - ex.getMessage() << "zmq_connect() failed: " << zmqErrnoToStr(savedErrno); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// send -//------------------------------------------------------------------------------ -void cta::mediachanger::ZmqSocketST::send(ZmqMsg &msg, const int flags) { - send(&msg.getZmqMsg(), flags); -} - -//------------------------------------------------------------------------------ -// send -//------------------------------------------------------------------------------ -void cta::mediachanger::ZmqSocketST::send(zmq_msg_t *const msg, const int flags) { - if(-1 == zmq_msg_send(msg, m_zmqSocket, flags)) { - const int savedErrno = errno; - cta::exception::Exception ex; - ex.getMessage() << "zmq_msg_send() failed: " << zmqErrnoToStr(savedErrno); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// recv -//------------------------------------------------------------------------------ -void cta::mediachanger::ZmqSocketST::recv(ZmqMsg &msg, const int flags) { - recv(&msg.getZmqMsg(), flags); -} - -//------------------------------------------------------------------------------ -// recv -//------------------------------------------------------------------------------ -void cta::mediachanger::ZmqSocketST::recv(zmq_msg_t *const msg, int flags) { - if(-1 == zmq_msg_recv (msg, m_zmqSocket, flags)) { - const int savedErrno = errno; - cta::exception::Exception ex; - ex.getMessage() << "zmq_msg_recv() failed: " << zmqErrnoToStr(savedErrno); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// getZmqSocket -//------------------------------------------------------------------------------ -void *cta::mediachanger::ZmqSocketST::getZmqSocket() const throw() { - return m_zmqSocket; -} diff --git a/mediachanger/ZmqSocketST.hpp b/mediachanger/ZmqSocketST.hpp deleted file mode 100644 index d4226e1c72ea8b679a1bc176e7c873e1bee9a42d..0000000000000000000000000000000000000000 --- a/mediachanger/ZmqSocketST.hpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * The CERN Tape Archive(CTA) project - * Copyright(C) 2015 CERN - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - *(at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include "mediachanger/ZmqSocket.hpp" - -namespace cta { -namespace mediachanger { - -/** - - * A "Single-Threaded" ZMQ socket. - * - * This concrete C++ class wraps a ZMQ socket. This class is intended for - * single-thread use. If a multi-threaded use is required then the ZmqSocketMT - * class should be used instead. - */ -class ZmqSocketST: public ZmqSocket { -public: - - /** - * Constructor. - * - * @param zmqContext The ZMQ context. - * @param socketType The type of the ZMQ socket. - */ - ZmqSocketST(void *const zmqContext, const int socketType); - - /** - * Destructor. - */ - ~ZmqSocketST() throw(); - - /** - * Closes the ZMQ socket. - */ - void close(); - - /** - * Binds the ZMQ socket to the specified endpoint. - * - * @param endpoint The endpoint to bind to. - */ - void bind(const std::string &endpoint); - - /** - * Connects the socket to the spedicied endpoint. - * - * @param endpoint The endpoint to connect to. - */ - void connect(const std::string &endpoint); - - /** - * Sends the specified ZMQ message over the socket. - * - * @param msg The ZMQ messge to be sent. - * @param flags See manual page of zmq_msg_send(). - */ - void send(ZmqMsg &msg, const int flags = 0); - - /** - * Sends the specified ZMQ message over the socket. - * - * @param msg The ZMQ messge to be sent. - * @param flags See manual page of zmq_msg_send(). - */ - void send(zmq_msg_t *const msg, const int flags = 0); - - /** - * Receives a ZMQ mesage from the socket. - * - * @param msg Output parameter: The received ZMQ messge. - * @param flags See manual page of zmq_msg_send(). - */ - void recv(ZmqMsg &msg, const int flags = 0); - - /** - * Receives a ZMQ mesage from the socket. - * - * @param msg Output parameter: The received ZMQ messge. - * @param flags See manual page of zmq_msg_send(). - */ - void recv(zmq_msg_t *const msg, const int flags = 0); - - /** - * Returns the ZMQ socket wrappeed by this class. - * - * @return The ZMQ socket wrappeed by this class. - */ - void *getZmqSocket() const throw(); - -private: - - /** - * The ZMQ socket. - */ - void *m_zmqSocket; - - /** - * Copy constructor made private to prevent copies. - */ - ZmqSocketST(const ZmqSocketST&); - - /** - * Assignment operator made private to prevent assignments. - */ - void operator=(const ZmqSocketST &); - -}; // class ZmqSocketST - -} // namespace mediachanger -} // namespace cta