You could send a zero length message with no (SND_MORE) flag to signify that’s the last part.
From: zeromq-dev <firstname.lastname@example.org>
On Behalf Of Al Grant
Sent: 08 August 2018 12:56
Subject: [zeromq-dev] Abandon a multipart message?
Is there a way to abandon a multipart message if for some reason
I can't complete sending all the parts? I.e.:
zmq_send(pubsock, ... ZMQ_SNDMORE)
... decide I don't want to send the rest of the message ...
zmq_abandon(pubsock); // does this exist
Without this, there's a risk that the next message sent - either a
single-part message with flags 0 or the first part of a multipart
message with ZMQ_SNDMORE - would be interpreted as the later
part of a multipart message.
An alternative way to do this would be to introduce a new send
flag meaning "first (or only) part of a message". If seen while
ZMQ_SNDMORE is outstanding it would abandon the previous
multipart message and release its resources (including calling
free-functions). This would be upwards compatible - flags 0 would
have its current meaning - but it would provide extra robustness
and the new ability to abandon sending multipart messages.
At the risk of bikeshedding, I'd suggest a flag ZMQ_SNDFIRST,
then ZMQ_SNDSINGLE could be an alias, with ZMQ_SNDMULTI
being defined as (ZMQ_SNDFIRST|ZMQ_SNDMORE).