19 struct sigaction action;
22 sigemptyset(&action.sa_mask);
23 sigaction(SIGINT, &action, NULL);
24 sigaction(SIGTERM, &action, NULL);
27 int main(
int argc,
char* argv[])
31 printf(
"Wrong number of arguments\nUsage: %s [filename]\n", argv[0]);
38 zmq::context_t context(1);
41 std::cout <<
"Trying to connect to [tcp://localhost:1666]\n" << std::endl;
43 zmq::socket_t subscriber(context, ZMQ_SUB);
44 subscriber.connect(
"tcp://localhost:1666");
47 subscriber.setsockopt(ZMQ_SUBSCRIBE,
"", 0);
49 printf(
"----------- Started -----------------\n");
51 bool first_message =
true;
52 std::ofstream file_os;
56 zmq::message_t update;
60 subscriber.recv(&update);
62 catch (zmq::error_t& e)
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");
static void s_signal_handler(int)
static void CatchSignals(void)
static bool s_interrupted
int main(int argc, char *argv[])