-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_client.cpp
35 lines (27 loc) · 997 Bytes
/
main_client.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <chrono>
#include <iostream>
#include <mutex>
#include <thread>
#include <zmq.hpp>
int main()
{
using namespace std::chrono_literals;
// initialize zmq context
zmq::context_t context{1};
// construct a reply socket and bind to interface
zmq::socket_t socket{context, zmq::socket_type::req};
// socket.connect("tcp://localhost:5555"); // connect to nge-connect ke open connection
socket.connect("ipc:///home/fr13nds/temp/ipc/hole.sock"); // connect to nge-connect ke open connection
// prepare request data
const std::string data{"client 👁"};
for (auto request_num = 0; request_num < 10; ++request_num) {
// send the request message
std::cout << "sending request..." << request_num << std::endl;
socket.send(zmq::buffer(data), zmq::send_flags::none);
// wait for reply server
zmq::message_t reply{};
socket.recv(reply, zmq::recv_flags::none);
std::cout << "received response: " << reply.to_string() << std::endl;
}
return 0;
}