[zeromq-dev] zmq_send() blocking on ZMQ_STREAM when client has disconnnected

Philippe Causse filimus at icloud.com
Wed Sep 26 15:11:44 CEST 2018

Dear ZeroMQ community,

I am wondering if this behaviour is normal: zmq_send() is blocking on ZMQ_STREAM when client has disconnected.

I have a simple server using a ZMQ_STREAM socket  to serve plain TCP clients.

When a client disconnects, ZeroMQ effectively delivers a disconnection indication in the form of 2 frames :   [ peer-identity,  empty ].

Then, if I attempt to send some frames using this peer-identity, the call blocks  (unless ZMQ_DONTWAIT is given).
Shouldn’t it return EHOSTUNREACH instead, since the client has gone ?

If I send to a non-existing peer-identity  (for example, by altering a byte), the call returns immediately with EHOSTUNREACH.

But why does it block on a previously used identity, since the client connection doesn’t exist anymore ?
Doing “lsof”  on the process effectively shows that the socket is gone.  

Since the ZeroMQ socket is the receiver of the connection and not the initiator,  I don’t understand why this call should block.

Thank you for your help !

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1623 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20180926/78a88663/attachment.bin>

More information about the zeromq-dev mailing list