coral
A C++ library for distributed co-simulation
|
A server socket for communication with one or more client nodes in a request-reply pattern. More...
#include "coral/net/zmqx.hpp"
Public Member Functions | |
RepSocket () | |
Constructs a new, unconnected socket. | |
void | Bind (const coral::net::Endpoint &localEndpoint) |
Binds to a local endpoint and waits for incoming requests from clients. More... | |
void | Connect (const coral::net::Endpoint &clientEndpoint) |
Connects to a single client and waits for incoming requests from it. More... | |
void | Close () |
Disconnects and/or unbinds the socket. More... | |
const coral::net::Endpoint & | BoundEndpoint () const |
Returns the endpoint this socket has been bound to, or the endpoint of the proxy it is connected to along with the socket identity. | |
void | Receive (std::vector< zmq::message_t > &msg) |
Receives a request. More... | |
void | Send (std::vector< zmq::message_t > &msg) |
Sends a reply. More... | |
void | Ignore () |
Ignores the last received request. More... | |
zmq::socket_t & | Socket () |
The underlying ZMQ socket. More... | |
A server socket for communication with one or more client nodes in a request-reply pattern.
This is similar to a ZeroMQ REP socket, except that it is not limited to a strict alternating receive/send sequence: The Receive() function may be called again without an intervening Send(), which will cause the previous request to be ignored.
void coral::net::zmqx::RepSocket::Bind | ( | const coral::net::Endpoint & | localEndpoint | ) |
Binds to a local endpoint and waits for incoming requests from clients.
This function may only be called if the socket is not already connected or bound.
void coral::net::zmqx::RepSocket::Close | ( | ) |
Disconnects and/or unbinds the socket.
If the socket is not connected or bound, this function has no effect.
void coral::net::zmqx::RepSocket::Connect | ( | const coral::net::Endpoint & | clientEndpoint | ) |
Connects to a single client and waits for incoming requests from it.
This function may only be called if the socket is not already connected or bound.
void coral::net::zmqx::RepSocket::Ignore | ( | ) |
Ignores the last received request.
This enables calling Receive() to receive a new request without first sending a reply to the last one. After calling this function, it is an error to attempt to call Send() before a new request has been received.
If the socket is not connected, or no request has been received, this function has no effect.
void coral::net::zmqx::RepSocket::Receive | ( | std::vector< zmq::message_t > & | msg | ) |
void coral::net::zmqx::RepSocket::Send | ( | std::vector< zmq::message_t > & | msg | ) |
zmq::socket_t& coral::net::zmqx::RepSocket::Socket | ( | ) |
The underlying ZMQ socket.
This reference is only valid after the socket has been connected/bound. The socket is of type ROUTER.