coral
A C++ library for distributed co-simulation
Public Member Functions | List of all members
coral::net::zmqx::RepSocket Class Reference

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::EndpointBoundEndpoint () 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...
 

Detailed Description

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.

Member Function Documentation

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)

Receives a request.

The sender's identity will be stored and used when a reply is sent with Send().

This function may only be called if the socket is connected or bound, and may not be called again before a reply has been sent with Send() or the request has been ignored with Ignore().

void coral::net::zmqx::RepSocket::Send ( std::vector< zmq::message_t > &  msg)

Sends a reply.

This function may only be called if the socket is connected or bound, and then only after a request has been received with Receive() and it has not been ignored with Ignore().

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.


The documentation for this class was generated from the following file: