Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Hello World server in C++
- // Binds REP socket to tcp://*:5555
- // Expects "Hello" from client, replies with "World"
- //
- #include <string>
- #include <iostream>
- #ifndef _WIN32
- #include <unistd.h>
- #else
- #include <windows.h>
- #endif
- #include "zmq.hpp"
- int main () {
- // Prepare our context and socket
- zmq::context_t context (1);
- std::cout << "Hello. \n";
- //zmq::socket_t socket (context, ZMQ_REP);
- //socket.bind ("tcp://*:5555");
- /*
- while (true) {
- zmq::message_t request;
- //Wait for next request from client
- socket.recv (&request);
- std::cout << "Received Hello" << std::endl;
- // Do some 'work'
- #ifndef _WIN32
- sleep(1);
- #else
- Sleep (1);
- #endif
- // Send reply back to client
- zmq::message_t reply (5);
- memcpy ((void *) reply.data (), "World", 5);
- socket.send (reply);
- }
- */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement