From ec81f8fb2523e1e2fe45eaadc05311a35bf551d7 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Wed, 22 Jun 2011 11:02:16 +0200 Subject: New wire format for REQ/REP pattern This patch introduces two changes: 1. 32-bit ID is used to identify the peer instead of UUID 2. REQ socket seeds the label stack with unique 32-bit request ID It also drops any replies with non-matching request ID Signed-off-by: Martin Sustrik --- src/xrep.hpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/xrep.hpp') diff --git a/src/xrep.hpp b/src/xrep.hpp index fbc7385..d5014e0 100644 --- a/src/xrep.hpp +++ b/src/xrep.hpp @@ -25,7 +25,7 @@ #include #include "socket_base.hpp" -#include "blob.hpp" +#include "stdint.hpp" #include "msg.hpp" namespace zmq @@ -41,7 +41,8 @@ namespace zmq ~xrep_t (); // Overloads of functions from socket_base_t. - void xattach_pipe (class pipe_t *pipe_, const blob_t &peer_identity_); + void xattach_pipe (class pipe_t *pipe_, + const blob_t &peer_identity_); int xsend (class msg_t *msg_, int flags_); int xrecv (class msg_t *msg_, int flags_); bool xhas_in (); @@ -60,7 +61,7 @@ namespace zmq struct inpipe_t { class pipe_t *pipe; - blob_t identity; + uint32_t peer_id; bool active; }; @@ -86,8 +87,8 @@ namespace zmq bool active; }; - // Outbound pipes indexed by the peer names. - typedef std::map outpipes_t; + // Outbound pipes indexed by the peer IDs. + typedef std::map outpipes_t; outpipes_t outpipes; // The pipe we are currently writing to. @@ -96,6 +97,10 @@ namespace zmq // If true, more outgoing message parts are expected. bool more_out; + // Peer ID are generated. It's a simple increment and wrap-over + // algorithm. This value is the next ID to use (if not used already). + uint32_t next_peer_id; + xrep_t (const xrep_t&); const xrep_t &operator = (const xrep_t&); }; -- cgit v1.2.3