[zeromq-dev] Terminating before receiving reply on ZMQ_REQ?

Andrei Zmievski andrei at zmievski.org
Tue Jun 19 19:25:23 CEST 2012

> Could you post up the snippet of code that demonstrates the issue? One
> thing to check: is LINGER set after the connection is made - it must be set
> before a given connection to effect it. (so setsockopt(), connect(), rather
> than connect(), setsockopt()).
> Ian

Not sure there's much to post. Here's how I create the socket:

    int linger = 0;
    int64_t hwm = 1;

    socket = new zmq::socket_t(*AG(zmq_ctx), ZMQ_REQ);
    socket->setsockopt(ZMQ_LINGER, &linger, sizeof(int));
    socket->setsockopt(ZMQ_HWM, &hwm, sizeof(int64_t));

    try {
    } catch (zmq::error_t e) {
        LOG_INFO(logger, "exception when connecting the socket: " << e.what());
        return false;

After that I just use s_send() helper macro to send the message. But
as I said, if I try to terminate the process before trying to receive
the reply, it blocks for some time.


More information about the zeromq-dev mailing list