[zeromq-dev] discussion on the Lasy Pirate Client : lpclient.c

Pieter Hintjens ph at imatix.com
Thu Jun 6 14:18:09 CEST 2013


Hi Laurent,

I'll try to answer your questions.

1. CZMQ destroys all sockets in a context automatically, correctly
setting linger so the application does not hang. We don't destroy
sockets ourselves.

2. You may detect a Ctrl-C interrupt, or get an ETERM error on a
blocking operation. You may get both conditions, or either, but you
need to test for both. Particularly, one thread may catch the
interrupt, while another gets the ETERM signal via the context.

3. If there's no ZMQ_POLLIN bit set on items[0].revents, that means we
timed-out, which means the server isn't responding.

4. If the reply is malformed, we throw it away. This should never
happen, However assuming it might, you'd want to keep trying for a
valid reply from (probably) another server.

5. You can use zmq_poll and RCVTIMEO on REQ sockets without affecting
the send/receive contraint, to avoid waiting forever. However if you
don't get a reply you have to then destroy and recreate the socket.

> To clarify my thoughts, I would have written it like this :
> http://pastebin.com/DCKXedQL

Sure... you can write this in many ways. My goal is always to write
the simplest possible code.

-Pieter



More information about the zeromq-dev mailing list