As we all know, a ZeroMQ socket shall not be shared among application threads.context_t
instances however can.
I have a multi-threaded-application a
I think one different is performance.
With above code, that means you need do 20k times of create socket, establish connection, send message and close socket, which is time consuming from my perspective and you can run some performance tool analysis to check how much time is used in function sendMessage()
.
An alternative approach might create one request socket for each thread, and send data with socket of that thread it belongs to. ZeroMQ is not support multiple thread, or it will lead to errors, such as assert error (debug mode) or crash.