AirInv Logo  1.00.0
C++ Simulated Airline Inventory Management System library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 /////////////////////
11 int 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  socket.send (request);
25 
26  // Get the reply.
27  zmq::message_t reply;
28  socket.recv (&reply);
29  std::cout << "Received World " << request_nbr << std::endl;
30  }
31  return 0;
32 }