// Hello World server #include #include #include #include #include #include #include using std::string; using std::cout; using std::endl; struct send_msg { int msgId; string msgData; }; int main (void) { // Socket to talk to clients void *context = zmq_ctx_new (); void *responder = zmq_socket (context, ZMQ_REP); int rc = zmq_bind (responder, "tcp://*:5555"); assert (rc == 0); while (1) { send_msg msg; memset(&msg, 0, sizeof(send_msg)); char buffer [10]; cout << "Recv Message..." << endl; zmq_recv (responder, &msg, sizeof(send_msg), 0); cout << "Received msgid: " << msg.msgId << ", msdData: " << msg.msgData << endl; //printf ("Received msgid: %d, msdData: %s\n",msg.msgId,msg.msgData); sleep (1); // Do some 'work' zmq_send (responder, "World", 5, 0); } return 0; }