|
lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
|
Wraps one ZeroMQ socket created from a ZmqContext. More...
#include <Collection.hh>
Public Member Functions | |
| ZmqSocket (ZmqContext *context, int type) | |
| Create a socket of the given ZeroMQ type in context. | |
| ~ZmqSocket () | |
| Close the socket. | |
| void | connect (const std::string &host) |
| Connect the socket to the endpoint host; throws std::runtime_error on failure. | |
| void | bind (const std::string &host) |
| Bind the socket to the endpoint host; throws std::runtime_error on failure. | |
| void | setsockopt (int option, const void *optval, size_t optvallen) |
| Set a socket option; throws std::runtime_error on failure. | |
| std::string | recv () |
| Receive one frame and return it as a string; logs an error and returns an empty string if the receive fails. | |
| nlohmann::json | recvJson () |
| Receive one frame and parse it as JSON; logs an error and returns an empty JSON object if the receive fails. | |
| std::vector< ZmqMessage > | recvMultipart () |
| Receive all frames of one multi-part message; returns an empty vector (after logging) if a receive or ZMQ_RCVMORE query fails. | |
| void | send (const std::string &msg) |
| Send msg as one frame; a failure is only logged. | |
| int | poll (short events, long timeout) |
| Poll this socket for events for up to timeout (zmq_poll() units) and return the zmq_poll() result. | |
Public Attributes | |
| void * | socket |
| Raw ZeroMQ socket handle. | |
Wraps one ZeroMQ socket created from a ZmqContext.
| ZmqSocket::ZmqSocket | ( | ZmqContext * | context, |
| int | type | ||
| ) |
Create a socket of the given ZeroMQ type in context.
|
inline |
Close the socket.
| void ZmqSocket::bind | ( | const std::string & | host | ) |
Bind the socket to the endpoint host; throws std::runtime_error on failure.
| void ZmqSocket::connect | ( | const std::string & | host | ) |
Connect the socket to the endpoint host; throws std::runtime_error on failure.
| int ZmqSocket::poll | ( | short | events, |
| long | timeout | ||
| ) |
Poll this socket for events for up to timeout (zmq_poll() units) and return the zmq_poll() result.
| std::string ZmqSocket::recv | ( | ) |
Receive one frame and return it as a string; logs an error and returns an empty string if the receive fails.
| nlohmann::json ZmqSocket::recvJson | ( | ) |
Receive one frame and parse it as JSON; logs an error and returns an empty JSON object if the receive fails.
| std::vector< ZmqMessage > ZmqSocket::recvMultipart | ( | ) |
Receive all frames of one multi-part message; returns an empty vector (after logging) if a receive or ZMQ_RCVMORE query fails.
| void ZmqSocket::send | ( | const std::string & | msg | ) |
Send msg as one frame; a failure is only logged.
| void ZmqSocket::setsockopt | ( | int | option, |
| const void * | optval, | ||
| size_t | optvallen | ||
| ) |
Set a socket option; throws std::runtime_error on failure.
| void* ZmqSocket::socket |
Raw ZeroMQ socket handle.