In one of my applications, I use inproc connections for DEALER / ROUTER. I set the linger option on the DEALER jack to 0, so all messages sent to the DEALER jack should be reset after closing the ROUTER jack. Although this works well for TCP connections, it blocks forproc. Here is a minimal working example:
#include <zmq.h>
#include <windows.h>
int main()
{
void *context = zmq_ctx_new();
void *router = zmq_socket(context, ZMQ_ROUTER);
zmq_bind(router, "inproc://socket");
void *dealer = zmq_socket(context, ZMQ_DEALER);
zmq_connect(dealer, "inproc://socket");
int linger = 0;
zmq_setsockopt(dealer, ZMQ_LINGER, &linger, sizeof(linger));
zmq_close(router);
Sleep(1);
zmq_send(dealer, "message", 7, 0);
zmq_close(dealer);
zmq_ctx_destroy(context);
return 0;
}
Before the DEALER connector can be closed, it blocks the call to zmq_send (). In this minimal example, I had to add a call to Sleep (1). When this call is omitted, zmq_send () is not blocked. When blocked, the call stack looks like this:
[External Code]
libzmq.dll!zmq::signaler_t::wait(int timeout_) Line 253 C++
libzmq.dll!zmq::mailbox_t::recv(zmq::command_t * cmd_, int timeout_) Line 80 C++
libzmq.dll!zmq::socket_base_t::process_commands(int timeout_, bool throttle_) Line 1023 C++
libzmq.dll!zmq::socket_base_t::send(zmq::msg_t * msg_, int flags_) Line 869 C++
libzmq.dll!s_sendmsg(zmq::socket_base_t * s_, zmq_msg_t * msg_, int flags_) Line 346 C++
libzmq.dll!zmq_send(void * s_, const void * buf_, unsigned __int64 len_, int flags_) Line 371 C++
Windows 10 x64, libzmq 4.2.1 ( 4.1.6) Visual Studio 2015. DEALER/ROUTER? libzmq?