Advertisement
Guest User

Untitled

a guest
Feb 26th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. // Hello World server in C++
  2. // Binds REP socket to tcp://*:5555
  3. // Expects "Hello" from client, replies with "World"
  4. //
  5.  
  6. #include <string>
  7. #include <iostream>
  8. #ifndef _WIN32
  9. #include <unistd.h>
  10. #else
  11. #include <windows.h>
  12. #endif
  13.  
  14. #include "zmq.hpp"
  15.  
  16. int main () {
  17. // Prepare our context and socket
  18.     zmq::context_t context (1);
  19.  
  20.     std::cout << "Hello. \n";
  21.     //zmq::socket_t socket (context, ZMQ_REP);
  22.     //socket.bind ("tcp://*:5555");
  23.     /*
  24.  
  25.     while (true) {
  26.         zmq::message_t request;
  27.  
  28.         //Wait for next request from client
  29.         socket.recv (&request);
  30.         std::cout << "Received Hello" << std::endl;
  31.  
  32.         // Do some 'work'
  33.         #ifndef _WIN32
  34.         sleep(1);
  35.         #else
  36.         Sleep (1);
  37.         #endif
  38.  
  39.         // Send reply back to client
  40.         zmq::message_t reply (5);
  41.         memcpy ((void *) reply.data (), "World", 5);
  42.         socket.send (reply);
  43.     }
  44.     */
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement