[zeromq-dev] Multi-threaded server example: issue with multiple clients

Radu Braniste rbraniste at gmail.com
Wed Jul 21 18:06:34 CEST 2010


Martin,

I’m using the client from
http://www.zeromq.org/local--files/blog:multithreaded-server/client.cpp
and the server from
http://www.zeromq.org/local--files/blog:multithreaded-server/server.cpp
with no modifications, other than printing a counter from the client:

#include <zmq.hpp>
#include <string.h>
#include <stdio.h>

int main ()
{
    //  One I/O thread in the thread pool will do.
    zmq::context_t ctx (1);

    //  This client is a requester.
    zmq::socket_t s (ctx, ZMQ_REQ);

    //  Connect to the server.
    s.connect ("tcp://localhost:5555");

    // Send 20 requests and receive 20 replies.
    for (int i = 0; i != 20; i++) {

        //  Send the request. No point in filling the content in as server
        //  is a dummy and won't use it anyway.
        zmq::message_t request (10);
        memset (request.data (), 0, request.size ());
        s.send (request);

        //  Get the reply.
        zmq::message_t reply;
        s.recv (&reply);

//extra
printf(".");
fflush(stdout);
    }

    return 0;
}

Thanks
Radu



More information about the zeromq-dev mailing list