mirror of
				https://github.com/zeromq/libzmq.git
				synced 2025-10-30 05:29:43 +01:00 
			
		
		
		
	problem: router doesn't know when peer disconnected
ZMQ_ROUTER_NOTIFY doesn't have a context and doesn't play nice with protocols. with ZMQ_DISCONNECT_MSG we can set it to a protocol message, like DISCONNECT in majordomo. Router will send it when a peer is disconnected. Another advantage of ZMQ_DISCONNECT_MSG is that it also works on inproc. Together with ZMQ_HEARTBEAT it allows to build very reliable protocols, and much simpler as well.
This commit is contained in:
		| @@ -38,10 +38,10 @@ | ||||
| #include "blob.hpp" | ||||
| #include "options.hpp" | ||||
| #include "endpoint.hpp" | ||||
| #include "msg.hpp" | ||||
|  | ||||
| namespace zmq | ||||
| { | ||||
| class msg_t; | ||||
| class pipe_t; | ||||
|  | ||||
| //  Create a pipepair for bi-directional transfer of messages. | ||||
| @@ -147,6 +147,9 @@ class pipe_t ZMQ_FINAL : public object_t, | ||||
|  | ||||
|     void send_stats_to_peer (own_t *socket_base_); | ||||
|  | ||||
|     void send_disconnect_msg (); | ||||
|     void set_disconnect_msg (const std::vector<unsigned char> &disconnect_); | ||||
|  | ||||
|   private: | ||||
|     //  Type of the underlying lock-free pipe. | ||||
|     typedef ypipe_base_t<msg_t> upipe_t; | ||||
| @@ -257,6 +260,9 @@ class pipe_t ZMQ_FINAL : public object_t, | ||||
|     // The endpoints of this pipe. | ||||
|     endpoint_uri_pair_t _endpoint_pair; | ||||
|  | ||||
|     // Disconnect msg | ||||
|     msg_t _disconnect_msg; | ||||
|  | ||||
|     ZMQ_NON_COPYABLE_NOR_MOVABLE (pipe_t) | ||||
| }; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Doron Somech
					Doron Somech