ReCodEx - Task Broker
ReCodEx is complex programmer testing solution, primary targeted to technical universities. It's highly customizable and based on modern technologies.
socket_wrapper_base Class Referenceabstract

#include <socket_wrapper_base.h>

+ Inheritance diagram for socket_wrapper_base:

Public Member Functions

 socket_wrapper_base (std::shared_ptr< zmq::context_t > context, zmq::socket_type type, const std::string &addr, const bool bound)
 
virtual ~socket_wrapper_base ()
 
zmq_pollitem_t get_pollitem ()
 
virtual void initialize ()
 
void restart ()
 
virtual bool send_message (const message_container &)=0
 
virtual bool receive_message (message_container &)=0
 

Protected Attributes

zmq::socket_t socket_
 
const std::string addr_
 
const bool bound_
 

Detailed Description

A wrapper for ZeroMQ sockets that also contains the address the socket should use, so that we can easily restart the connection. Socket wrappers should also hide all technical details of the underlying sockets, such as empty delimiter frames.

Definition at line 14 of file socket_wrapper_base.h.

Constructor & Destructor Documentation

§ socket_wrapper_base()

socket_wrapper_base::socket_wrapper_base ( std::shared_ptr< zmq::context_t >  context,
zmq::socket_type  type,
const std::string &  addr,
const bool  bound 
)
Parameters
contextA ZeroMQ context used to create the socket
typeType of the socket
addrAddress used by the socket
boundTrue if the socket should bind to an address, false if it connects

Definition at line 4 of file socket_wrapper_base.cpp.

§ ~socket_wrapper_base()

socket_wrapper_base::~socket_wrapper_base ( )
virtual

A virtual destructor

Definition at line 11 of file socket_wrapper_base.cpp.

Member Function Documentation

§ get_pollitem()

zmq_pollitem_t socket_wrapper_base::get_pollitem ( )

Get the pollitem structure used to poll the wrapped socket

Returns
A ZeroMQ poll item structure

Definition at line 15 of file socket_wrapper_base.cpp.

§ initialize()

void socket_wrapper_base::initialize ( )
virtual

Connect or bind the socket

Definition at line 31 of file socket_wrapper_base.cpp.

§ receive_message()

virtual bool socket_wrapper_base::receive_message ( message_container )
pure virtual

Receive a message from the socket

Returns
true on success, false otherwise

Implemented in router_socket_wrapper.

§ restart()

void socket_wrapper_base::restart ( )

Destroy the wrapped socket and connect/bind again with a new one

Definition at line 20 of file socket_wrapper_base.cpp.

§ send_message()

virtual bool socket_wrapper_base::send_message ( const message_container )
pure virtual

Send a message through the socket

Returns
true on success, false otherwise

Implemented in router_socket_wrapper.

Member Data Documentation

§ addr_

const std::string socket_wrapper_base::addr_
protected

An address to connect/bind to

Definition at line 25 of file socket_wrapper_base.h.

§ bound_

const bool socket_wrapper_base::bound_
protected

True if the socket should bind to an address, false if it connects

Definition at line 30 of file socket_wrapper_base.h.

§ socket_

zmq::socket_t socket_wrapper_base::socket_
protected

The wrapped socket

Definition at line 20 of file socket_wrapper_base.h.


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