zeromq / cppzmq

Header-only C++ binding for libzmq
http://www.zeromq.org
MIT License
1.93k stars 757 forks source link

add a parameter for multipart_t::send #569

Closed caicaiking closed 1 year ago

caicaiking commented 1 year ago

I need send message and recv message to do ACK, when I not recv the ack message I need to send it again. I don't want to use clone, because need time to copy.

gummif commented 1 year ago

Thos function is destructive so clear is a no-op it looks like. Copying messages is really the only way.

caicaiking commented 1 year ago

Thos function is destructive so clear is a no-op it looks like. Copying messages is really the only way.

So, Can I add this control parameter for send funciton?

gummif commented 1 year ago

What you really need to do is something like this

std::vector<zmq::const_buffer> bufs;
for (const auto& m : msgs)
  bufs.emplace_back(m.data(), m.size());
while (not done)
{
  auto ret = zmq::send_multipart(bufs);
  // repeat send until something
}

Make a vector/array of buffers and use the send_multipart function (which will not modify the messages).