[zeromq-dev] Empty message does not close ZMQ_STREAM socket?

KIU Shueng Chuan nixchuan at gmail.com
Wed Mar 23 03:31:43 CET 2016

Hi Jens,

I did some more experimentation, and the following sequence works to cause
the client disconnection:

// send client some data
server.send(id.data(), id.size(), ZMQ_SNDMORE);
server.send("A", 1, ZMQ_SNDMORE);
// disconnect client
server.send(id.data(), id.size(), ZMQ_SNDMORE);
server.send("", 0, ZMQ_SNDMORE);

In your example code, the server was immediately disconnecting the client
without having sent it any other bytes.
So it would seem that you have hit a corner case in ZMQ_STREAM.

Should this be considered a zmq bug?

On Tue, Mar 22, 2016 at 11:11 PM, Auer, Jens <jens.auer at cgi.com> wrote:

> Hi,
> ZMQ_STREAM sockets are special and do not follow the normal behavior w.r.t
> ZMQ_SNDMORE. You always have to send two messages, the first one is
> discarded as the identity frame. If you omit ZMQ_SNDMORE once, you will not
> be able to send any messages over the socket again.
> I also tried with and without ZMQ_SNDMORE for the empty message. It does
> not make a difference, but sending it twice does.
> Cheers,
>   Jens
> --
> *Jens Auer *| CGI | Software-Engineer
> CGI (Germany) GmbH & Co. KG
> Rheinstraße 95 | 64295 Darmstadt | Germany
> T: +49 6151 36860 154
> *jens.auer at cgi.com* <jens.auer at cgi.com>
> Unsere Pflichtangaben gemäß § 35a GmbHG / §§ 161, 125a HGB finden Sie unter
> *de.cgi.com/pflichtangaben* <http://de.cgi.com/pflichtangaben>.
> CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to
> CGI Group Inc. and its affiliates may be contained in this message. If you
> are not a recipient indicated or intended in this message (or responsible
> for delivery of this message to such person), or you think for any reason
> that this message may have been addressed to you in error, you may not use
> or copy or deliver this message to anyone else. In such case, you should
> destroy this message and are asked to notify the sender by reply e-mail.
> ------------------------------
> *Von:* zeromq-dev-bounces at lists.zeromq.org [
> zeromq-dev-bounces at lists.zeromq.org]" im Auftrag von "Osiris Pedroso [
> opedroso at gmail.com]
> *Gesendet:* Dienstag, 22. März 2016 15:03
> *An:* ZeroMQ development list; KIU Shueng Chuan
> *Betreff:* Re: [zeromq-dev] Empty message does not close ZMQ_STREAM
> socket?
> If I am completely off here, please let me know (still learning ZMQ):
>     server.send(id, ZMQ_SNDMORE);
>     server.send(empty, ZMQ_SNDMORE );
> But I don't think you should have the ZMQ_SENDMORE flag on the second
> send() call.
> Otherwise the message will not be sent, instead waiting for another call
> to send() without the flag which only then commits the message to be sent
> by underlying code.
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20160323/831566e0/attachment.htm>

More information about the zeromq-dev mailing list