19 struct sigaction action;
22 sigemptyset(&action.sa_mask);
23 sigaction(SIGINT, &action,
nullptr);
24 sigaction(SIGTERM, &action,
nullptr);
27 int main(
int argc,
char* argv[])
31 printf(
"Wrong number of arguments\nUsage: %s [filename]\n", argv[0]);
41 std::cout <<
"Trying to connect to [tcp://localhost:1666]\n" << std::endl;
44 subscriber.
connect(
"tcp://localhost:1666");
47 subscriber.set(zmq::sockopt::subscribe,
"");
49 printf(
"----------- Started -----------------\n");
51 bool first_message =
true;
52 std::ofstream file_os;
60 subscriber.recv(update, zmq::recv_flags::none);
66 std::cout <<
"subscriber.recv() failed with exception: " << e.
what() << std::endl;
73 char* data_ptr =
static_cast<char*
>(update.
data());
74 const uint32_t header_size = flatbuffers::ReadScalar<uint32_t>(data_ptr);
78 printf(
"First message received\n");
79 first_message =
false;
81 file_os.open(argv[1], std::ofstream::binary | std::ofstream::out);
82 file_os.write(data_ptr, 4 + header_size);
84 data_ptr += 4 + header_size;
86 const uint32_t transition_count = flatbuffers::ReadScalar<uint32_t>(data_ptr);
87 data_ptr +=
sizeof(uint32_t);
89 file_os.write(data_ptr, 12 * transition_count);
95 printf(
"Results saved to file\n");
virtual const char * what() const ZMQ_NOTHROW ZMQ_OVERRIDE
static void s_signal_handler(int)
void * data() ZMQ_NOTHROW
static void CatchSignals(void)
void connect(std::string const &addr)
static bool s_interrupted
int main(int argc, char *argv[])