AirInv Logo  1.00.10
C++ Simulated Airline Inventory Management System Library
Loading...
Searching...
No Matches
AirInvClient.cpp
Go to the documentation of this file.
1// //////////////////////////////////////////////////////////////////////
2// Import section
3// //////////////////////////////////////////////////////////////////////
4// STL
5#include <string>
6#include <iostream>
7// ZeroMQ
8#include <zmq.hpp>
9
10// ////////////////// M A I N /////////////////////
11int main (int argc, char* argv[]) {
12 // Prepare our context and socket
13 zmq::context_t context (1);
14 zmq::socket_t socket (context, ZMQ_REQ);
15
16 std::cout << "Connecting to hello world server…" << std::endl;
17 socket.connect ("tcp://localhost:5555");
18
19 // Do 10 requests, waiting each time for a response
20 for (int request_nbr = 0; request_nbr != 10; request_nbr++) {
21 zmq::message_t request (6);
22 memcpy ((void *) request.data (), "Hello", 5);
23 std::cout << "Sending Hello " << request_nbr << "…" << std::endl;
24
25 zmq::send_flags flags = zmq::send_flags::none;
26 // zmq::send_result_t rc =
27 socket.send (request, flags);
28 // std::cout << "Result of sending paylod: " << rc << std::endl;
29
30 // Get the reply.
31 zmq::message_t reply;
32 socket.recv (reply);
33 std::cout << "Received World " << request_nbr << std::endl;
34 }
35 return 0;
36}
int main(int argc, char *argv[])