[zeromq-dev] Async client server with multiple sockets

Artem Vysochyn artem.vysochyn at gmail.com
Thu Sep 26 21:57:15 CEST 2013

Aayush :)

What you are describing here is extermely cool, but that
"architecture" you described (I read it very carefully) renders the
fact that you did not really read the guide, or just "scratched a

Seriously, read the guide.

2013/9/26 aayush gupta <aayushgupta.84 at gmail.com>:
> Hi,
> I am a newbie to using zmq. I am building my client server architecture (C
> client/server) as follows.
> I have 2 threads in my client and 2 threads in my server.
> I create a DEALER socket in Thread 1 of my client and it sends requests to
> the server. Thread 2 has a PULL socket and waits for response from the
> server. This way Thread 1 can keep sending requests while Thread 2 keeps
> processing responses as and when they are available.
> On the server side, Thread 1 creates 2 sockets: A ROUTER socket where it
> receives requests from clients (with their identities) and a PUSH socket
> which it hands over to Thread 2 through which Thread 2 sends responses back
> to clients. Since thread 1 never does anything to the PUSH socket, I believe
> it should be safe to create both sockets in Thread 1 and hand over the PUSH
> socket to the worker thread.
> When Thread 1 receives requests from clients, it signals the worker Thread 2
> to process the requests. Note, I do not use zmq_proxy for communication
> between the 2 server threads. Instead, the content of the message is made
> available to Thread 2 through my own mechanism (the content of messages from
> clients can be large, hence I cannot pay the penalty of multiple memcpy's on
> recv()).
> After worker Thread 2 finishes processing, it sends response back to client
> using the PUSH socket.
> My concern is that if there are multiple clients talking to the server, how
> will the worker Thread be able to decide which client to respond to (i.e. I
> do not want the worker thread to send replies to wrong clients).
> If I were using native socket library, I could have associated the socket
> descriptors after accept() with each client and passed this information from
> Thread 1 to Thread 2 enabling it to respond to appropriate client. How do I
> achieve this behavior using zeroMQ?
> Any help would be greatly appreciated.
> Thanks,
> Aayush
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

More information about the zeromq-dev mailing list