We should note that the last part of the message lag that you send should always be
set to 0 . If you set it to ZMQ_SNDMORE , then the client will not receive any messages.
zmq_msg_t msg1, msg2, msg3, msg4, msg5;
zmq_msg_send(&msg1, respond, ZMQ_SNDMORE);
zmq_msg_send(&msg2, respond, ZMQ_SNDMORE);
zmq_msg_send(&msg3, respond, ZMQ_SNDMORE);
zmq_msg_send(&msg4, respond, ZMQ_SNDMORE);
zmq_msg_send(&msg5, respond, ZMQ_SNDMORE);
The previous code snippet will not work. You could change the relevant parts of
server code with it and experience it yourself.
How to handle interruptions
You need to close the applications properly when you interrupt your application
with signals such as SIGTERM or SIGINT . SIGTERM is one of the POSIX signals that
sends a signal to a process to end it. Signals are asynchronous and are vulnerable
to race conditions.
• SIGTERM : When you execute the kill command with its defaults in a Unix
system, you are basically calling a SIGTERM signal to the denoted process.
These signals should be handled properly so your application can release the
resources or close database connections and lush the messages properly.