0
0
mirror of https://github.com/zeromq/libzmq.git synced 2025-01-08 13:25:53 +08:00

Load identity message to decoder at start

This commit is contained in:
Martin Hurton 2013-06-21 16:23:38 +02:00 committed by Pieter Hintjens
parent b24db36057
commit 5490794666

View File

@ -480,6 +480,13 @@ bool zmq::stream_engine_t::handshake ()
// header data away.
const size_t header_size = options.identity_size + 1 >= 255 ? 10 : 2;
unsigned char tmp [10], *bufferp = tmp;
// Prepare the identity message and load it into encoder.
// Then consume bytes we have already sent to the peer.
const int rc = tx_msg.init_size (options.identity_size);
zmq_assert (rc == 0);
memcpy (tx_msg.data (), options.identity, options.identity_size);
encoder->load_msg (&tx_msg);
size_t buffer_size = encoder->encode (&bufferp, header_size);
zmq_assert (buffer_size == header_size);