On Thu, 2017-08-31 at 12:49 +0200, Stephan Opfer wrote: > Hi Luca, > > thank you for your hints. I am currently stuck with a little problem, > that is probably related to your hin about cleaning up the messages > to early. My current state is uploaded on gist: https://gist.github.c > om/StephanOpfer/98e32c13c822c33e06d56bc82956c7c2 > > The thing is, that the messages are transfered correctly, when my > process waits for some time, before it ends. So my question is, what > do I don't understand correctly here? > > My current impression, or explanation of this phenomenon, is that the > zmq_msg_send method is working asynchronously and the process ended, > before zmq can send everything correctly. > > If that is the case I am not sure, what the best way will be to > manage the data in my real application. How do I know, that zmq has > finished sending my data, so that it would be ok to delete it. If I > would let zmq decide to delete the data (by passing a deallocator > method to zmq_msg_init_data), it could happen that it deletes the > data to early for other parts of my application. > > Greetings, > Stephan
First of all, use the APIs to cleanly close the sockets and terminate the context. zmq_close (socket); zmq_ctx_term (ctx); When the socket is closed, there is grace periods for messages queued up to the I/O thread but not yet sent - this is called the ZMQ_LINGER timer. The default is 30 seconds. You can increase it (or set it to unlimited with -1) via zmq_setsockopt. Unlimited linger with TCP/IPC can lead to waiting forever if the other end disappears, but with UDP there should not be this problem IIRC, as it just sends the messages. -- Kind regards, Luca Boccassi
signature.asc
Description: This is a digitally signed message part
_______________________________________________ zeromq-dev mailing list zeromq-dev@lists.zeromq.org https://lists.zeromq.org/mailman/listinfo/zeromq-dev