[zeromq-dev] threaded client-server?

Pieter Hintjens ph at imatix.com
Fri Sep 23 00:23:34 CEST 2011


Jan,

So there are a few classic patterns.

One, your client apps are single threaded. They send requests, wait
for responses. Responses can take any time; apps wait and perhaps
timeout if impatient. Check the Majordomo pattern in the Guide for a
large-scale version of this.

Two, your client apps are multithreaded. They send multiple requests
and process responses on each one, but do not wait for responses. For
this, clients need to maintain a list of pending requests, and match
incoming responses with requests. They may resend requests if needed,
if you want to handle server failure.

In both cases, use one thread per client, and one socket per client.
In the first case a REQ socket would work; in the second you'd use
DEALER.

-Pieter



More information about the zeromq-dev mailing list