coral
A C++ library for distributed co-simulation
|
Functions and classes that extend or wrap the ZeroMQ API. More...
Classes | |
class | RepSocket |
A server socket for communication with one or more client nodes in a request-reply pattern. More... | |
class | ReqSocket |
A client socket for communication with a single server node. More... | |
Enumerations |
Functions | |
zmq::context_t & | GlobalContext () |
Returns a reference to a global ZMQ context. More... | |
std::uint16_t | BindToEphemeralPort (zmq::socket_t &socket, const std::string &networkInterface="*") |
Binds socket to an ephemeral TCP port on the given network interface and returns the port number. | |
std::string | LastEndpoint (zmq::socket_t &socket) |
Returns the value of the ZMQ_LAST_ENDPOINT socket property. More... | |
std::uint16_t | EndpointPort (const std::string &endpoint) |
Given a string on the form "tcp://addr:port", returns the port number. More... | |
bool | WaitForOutgoing (zmq::socket_t &socket, std::chrono::milliseconds timeout) |
Waits up to timeout milliseconds to see if a message may be enqueued on socket . More... | |
bool | WaitForIncoming (zmq::socket_t &socket, std::chrono::milliseconds timeout) |
Waits up to timeout milliseconds for incoming messages on socket . More... | |
void | Send (zmq::socket_t &socket, std::vector< zmq::message_t > &message, SendFlag flags=SendFlag::none) |
Sends a message. More... | |
void | Receive (zmq::socket_t &socket, std::vector< zmq::message_t > &message) |
Receives a message. More... | |
std::string | ToString (const zmq::message_t &frame) |
Returns the content of a message frame as a std::string . | |
zmq::message_t | ToFrame (const std::string &s) |
Returns a message frame whose contents are equal to s . | |
bool | Receive (RepSocket &socket, std::vector< zmq::message_t > &message, std::chrono::milliseconds timeout) |
Receives a message, given that one arrives before the timeout is reached. More... | |
Functions and classes that extend or wrap the ZeroMQ API.
The namespace name zmqx
stands for "ZeroMQ eXtensions", and was mainly chosen because zmq
caused all kinds of annoying name conflicts with the standard ZeroMQ C++ API.
|
strong |
Flags for the Send() function.
Enumerator | |
---|---|
none |
No flags are set. |
more |
The frames being sent are part of a multiframe message, and more frames are coming. |
std::uint16_t coral::net::zmqx::EndpointPort | ( | const std::string & | endpoint | ) |
Given a string on the form "tcp://addr:port", returns the port number.
std::invalid_argument | if endpoint does not have the structure described above. |
std::bad_cast | if the port number is not in a valid number format. |
zmq::context_t& coral::net::zmqx::GlobalContext | ( | ) |
Returns a reference to a global ZMQ context.
This function is thread safe as long as it is not used in a static initialisation setting.
std::string coral::net::zmqx::LastEndpoint | ( | zmq::socket_t & | socket | ) |
Returns the value of the ZMQ_LAST_ENDPOINT socket property.
zmq::error_t | if ZMQ reports an error. |
void coral::net::zmqx::Receive | ( | zmq::socket_t & | socket, |
std::vector< zmq::message_t > & | message | ||
) |
Receives a message.
Existing message content will be overwritten.
zmq::error_t | on failure to receive a message frame. |
bool coral::net::zmqx::Receive | ( | RepSocket & | socket, |
std::vector< zmq::message_t > & | message, | ||
std::chrono::milliseconds | timeout | ||
) |
Receives a message, given that one arrives before the timeout is reached.
Existing message content will be overwritten.
true
if a message was received, or false
if the function timed out. zmq::error_t | on failure to receive a message frame. |
void coral::net::zmqx::Send | ( | zmq::socket_t & | socket, |
std::vector< zmq::message_t > & | message, | ||
SendFlag | flags = SendFlag::none |
||
) |
Sends a message.
The message content will be cleared on return.
std::invalid_argument | if message is empty. |
zmq::error_t | on failure to send a message frame. |
bool coral::net::zmqx::WaitForIncoming | ( | zmq::socket_t & | socket, |
std::chrono::milliseconds | timeout | ||
) |
Waits up to timeout
milliseconds for incoming messages on socket
.
socket
. std::invalid_argument | if timeout is negative. |
zmq::error_t | on communications error. |
bool coral::net::zmqx::WaitForOutgoing | ( | zmq::socket_t & | socket, |
std::chrono::milliseconds | timeout | ||
) |
Waits up to timeout
milliseconds to see if a message may be enqueued on socket
.
socket
. std::invalid_argument | if timeout is negative. |
zmq::error_t | on communications error. |