Hi,

I'm experimenting with ​zmq_socket_monitor(). I have a XSUB socket that I'm 
monitoring. The monitoring works fine. I'm just trying to understand how I can 
enable/disable monitoring back-and-forth by calling zmq_socket_monitor().

I tried to enable/disable/re-enable monitoring by invoking zmq_socket_monitor() 
as shown below I get the error "Address already in use" on the 3rd invocation.

1) zmq_socket_monitor(my_xsub_sock, "inproc://starship-enterprise", 
ZMQ_EVENT_ALL);
2) zmq_socket_monitor(my_xsub_sock, NULL, 0);
3) zmq_socket_monitor(my_xsub_sock, "inproc://starship-enterprise", 
ZMQ_EVENT_ALL); <- ERROR

I followed the source code for zmq_socket_monitor() to a method called 
zmq::socket_base_t::monitor(). That function eventually calls zmq_bind() where 
I believe the error occurs. 

1) The first time zmq_socket_monitor() is called a ZMQ_PAIR socket is created 
(_monitor_socket) and bound to address "inproc://starship-enterprise". Note 
that this socket is created with ZMQ_LINGER=0.

2) The second time zmq_socket_monitor() is invoked to disable monitoring 
_monitor_socket is closed and because ZMQ_LINGER=0 it should go out of 
existence right away. Right?

3) The third time zmq_socket_monitor() is called I get "Address already in use" 
as if the old socket is still there. How can that be?

Regards,
Martin



_______________________________________________
zeromq-dev mailing list
[email protected]
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to