Hi,
I'm trying to use 0MQ in REQ/REP mode.
A question came appeared when I writing server-side code with RES 0MQ socket.
My question is : why the blocking sockets in 0MQ can handle multiple clients?
For example, there is a very simple server code :
while (1) {
// Wait for next request from client
zmq_msg_t request;
zmq_msg_init (&request);
zmq_recv (responder, &request, 0);
printf ("Received Hello\n");
zmq_msg_close (&request);
// Do some 'work'
sleep (1);
// Send reply back to client
zmq_msg_t reply;
zmq_msg_init_size (&reply, 5);
memcpy (zmq_msg_data (&reply), "World", 5);
zmq_send (responder, &reply, 0);
zmq_msg_close (&reply);
}
I thought that this code cannot handle multiple clients, but it can handle them.
It's very cool feature, however, I wonder why this code can handle
multiple clients.
With standard socket(), we have to use multiplexing IO (such as
epoll, kqueue, and so on).
What's happning inside 0MQ?
Best Regards,
OZAWA Tsuyoshi
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev