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.cpp
1 #include "socket_wrapper_base.h"
2 
3 
5  std::shared_ptr<zmq::context_t> context, zmq::socket_type type, const std::string &addr, const bool bound)
6  : addr_(addr), socket_(*context, type), bound_(bound)
7 {
8  socket_.setsockopt(ZMQ_LINGER, 0);
9 }
10 
12 {
13 }
14 
16 {
17  return zmq_pollitem_t{.socket = (void *) socket_, .fd = 0, .events = ZMQ_POLLIN, .revents = 0};
18 }
19 
21 {
22  if (bound_) {
23  socket_.unbind(addr_);
24  } else {
25  socket_.disconnect(addr_);
26  }
27 
28  initialize();
29 }
30 
32 {
33  if (bound_) {
34  socket_.bind(addr_);
35  } else {
36  socket_.connect(addr_);
37  }
38 }
zmq_pollitem_t get_pollitem()
const std::string addr_
socket_wrapper_base(std::shared_ptr< zmq::context_t > context, zmq::socket_type type, const std::string &addr, const bool bound)